class SlackMarkdown::Filters::CodeFilter

Constants

CODE_PATTERN

Public Instance Methods

call() click to toggle source
# File lib/slack_markdown/filters/code_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 = code_filter(content)
    next if html == content
    node.replace(html)
  end
  doc
end

Private Instance Methods

code_filter(text) click to toggle source
# File lib/slack_markdown/filters/code_filter.rb, line 25
def code_filter(text)
  text.gsub(CODE_PATTERN) do
    "<code>#{$1}</code>"
  end
end