Module: MCMarkdown::Formatter::EscapeMergeTags

Included in:
Base
Defined in:
lib/mc_markdown/formatters/escape_merge_tags.rb

Constant Summary collapse

ALLOWED_CHARACTERS =
['w', ':', '_', '<', '>', '/' ]

Instance Method Summary collapse

Instance Method Details

#convert_em_tags_to_underscores(string) ⇒ Object



15
16
17
# File 'lib/mc_markdown/formatters/escape_merge_tags.rb', line 15

def convert_em_tags_to_underscores string
  string.gsub( /<\/?em>/, '_' )
end

#emphasis(text) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/mc_markdown/formatters/escape_merge_tags.rb', line 6

def emphasis text
  characters = ALLOWED_CHARACTERS.map { |char| "\\#{char}" }.join("")
  unless text.match /^\| .+ \|$/x
    "<em>#{text}</em>"
  else
    "*#{convert_em_tags_to_underscores(text)}*"
  end
end