Module: Hipmost::Conversion
- Defined in:
- lib/hipmost/hipchat/conversion.rb
Class Method Summary collapse
Class Method Details
.convert_formatting_to_markdown(message) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hipmost/hipchat/conversion.rb', line 5 def self.convert_formatting_to_markdown() # According to Hipchat's docs, the only formatting commands which are # translatable to Mattermost are /code and /quote. # Relevant docs: https://confluence.atlassian.com/hipchat/keyboard-shortcuts-and-slash-commands-749385232.html#Keyboardshortcutsandslashcommands-Slashcommands if if .start_with?("/code") && .lines.count > 1 .sub!("/code", "```\n") << "\n```" elsif .start_with?("/code") && .lines.count == 1 .sub!("/code", "`") << "`" end if .start_with?("/quote") .sub!("/quote", ">") .gsub!(/\n\n(.)/, "\n\n> \\1") end end end |