class SlackMarkdown::Filters::ItalicFilter

Constants

ITALIC_PATTERN

Public Instance Methods

call() click to toggle source
# File lib/slack_markdown/filters/italic_filter.rb, line 11
def call
  doc.search('.//text()').each do |node|
    content = node.to_html
    next if has_ancestor?(node, ignored_ancestor_tags)
    next unless content.include?('_')
    html = italic_filter(content)
    next if html == content
    node.replace(html)
  end
  doc
end
italic_filter(text) click to toggle source
# File lib/slack_markdown/filters/italic_filter.rb, line 23
def italic_filter(text)
  text.gsub(ITALIC_PATTERN) do
    "<i>#{$1}</i>"
  end
end