Class: Jekyll::Converters::Markdown::CommonMark::HtmlRenderer

Inherits:
CommonMarker::HtmlRenderer
  • Object
show all
Defined in:
lib/jekyll-commonmark/html_renderer.rb

Instance Method Summary collapse

Instance Method Details

#code_block(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll-commonmark/html_renderer.rb', line 8

def code_block(node)
  block do
    lang = extract_code_lang(node.fence_info)

    out('<div class="')
    out("language-", lang, " ") if lang
    out('highlighter-rouge"><div class="highlight">')
    out("<pre", sourcepos(node), ' class="highlight"')

    if option_enabled?(:GITHUB_PRE_LANG)
      out_data_attr(lang)
      out("><code>")
    else
      out("><code")
      out_data_attr(lang)
      out(">")
    end
    out(render_with_rouge(node.string_content, lang))
    out("</code></pre></div></div>")
  end
end