class Kramdown::Converter::Slack
Converts a Kramdown::Document to Slack
. api.slack.com/docs/message-formatting
Constants
- SMART_QUOTES
- TYPOGRAPHIC_SYMBOLS
Attributes
bullet[R]
Public Instance Methods
__convert_todo(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 129 def __convert_todo(el) inner(el) end
convert(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 8 def convert(el) if el.type == :html_element converter = :"convert_html_#{el.value}" converter = :convert_html_element unless respond_to? converter else converter = :"convert_#{el.type}" end send(converter, el) end
convert_a(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 72 def convert_a(el) content = inner(el) return el.attr["href"] if content.nil? || content == "" "<#{el.attr["href"]}|#{content}>" end
Also aliased as: convert_html_a
convert_blank(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 32 def convert_blank(el) "" end
Also aliased as: convert_br, convert_comment
convert_blockquote(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 64 def convert_blockquote(el) "> #{inner(el)}" end
convert_codeblock(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 68 def convert_codeblock(el) "```\n#{el.value}```\n\n" end
convert_codespan(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 59 def convert_codespan(el) "`#{el.value}`" end
Also aliased as: convert_html_code
convert_dd(el)
The following are all tags converted by Kramdown::Converter::Html
Alias for: __convert_todo
convert_del(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 54 def convert_del(el) "~#{inner(el)}~" end
Also aliased as: convert_html_del
convert_em(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 48 def convert_em(el) "_#{inner(el)}_" end
Also aliased as: convert_html_i, convert_html_em
convert_entity(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 123 def convert_entity(el) el.value.char end
convert_header(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 101 def convert_header(el) "\n\n#{convert_strong(el)}\n" end
Also aliased as: convert_html_h1, convert_html_h2, convert_html_h3, convert_html_h4, convert_html_h5, convert_html_h6
convert_hr(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 111 def convert_hr(el) "----------------------------------------------\n\n" end
convert_html_br(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 38 def convert_html_br(el) "\n" end
convert_img(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 79 def convert_img(el) el.attr["src"] end
Also aliased as: convert_html_img
convert_li(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 96 def convert_li(el) " #{bullet.next} #{inner(el).strip}\n" end
Also aliased as: convert_html_li
convert_ol(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 90 def convert_ol(el) @bullet = OlBulletGenerator.new "#{inner(el)}\n" end
Also aliased as: convert_html_ol
convert_p(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 23 def convert_p(el) "#{inner(el).strip.gsub(/\n/, " ")}\n\n" end
convert_smart_quote(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 115 def convert_smart_quote(el) SMART_QUOTES.fetch(el.value) end
convert_strong(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 42 def convert_strong(el) "*#{inner(el)}*" end
Also aliased as: convert_html_b, convert_html_strong
convert_text(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 27 def convert_text(el) el.value end
Also aliased as: convert_abbreviation
convert_typographic_sym(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 119 def convert_typographic_sym(el) TYPOGRAPHIC_SYMBOLS.fetch(el.value) end
convert_ul(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 84 def convert_ul(el) @bullet = UlBulletGenerator.new "#{inner(el)}\n" end
Also aliased as: convert_html_ul
inner(el)
click to toggle source
# File lib/kramdown/converter/slack.rb, line 18 def inner(el) el.children.map { |el| convert(el) }.join end
Also aliased as: convert_root