Module: Bunto::Converters::Markdown::RedcarpetParser::CommonMethods

Included in:
WithPygments, WithoutHighlighting
Defined in:
lib/bunto/converters/markdown/redcarpet_parser.rb

Instance Method Summary collapse

Instance Method Details

#add_code_tags(code, lang) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/bunto/converters/markdown/redcarpet_parser.rb', line 3

def add_code_tags(code, lang)
  code = code.to_s
  code = code.sub(
    %r!<pre>!,
    "<pre><code class=\"language-#{lang}\" data-lang=\"#{lang}\">"
  )
  code = code.sub(%r!</pre>!, "</code></pre>")
  code
end