Class: BlueDoc::SML::Rules::Codeblock

Inherits:
Base
  • Object
show all
Extended by:
Rouge::Plugins::Redcarpet
Defined in:
lib/bluedoc/sml/rules/codeblock.rb

Constant Summary

Constants inherited from Base

Base::INDENT_PX

Class Method Summary collapse

Methods inherited from Base

to_text

Class Method Details

.match?(node) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/bluedoc/sml/rules/codeblock.rb', line 12

def self.match?(node)
  tag_name(node) == "codeblock"
end

.to_html(node, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/bluedoc/sml/rules/codeblock.rb', line 16

def self.to_html(node, opts = {})
  attrs = attributes(node)

  language = attrs[:language]
  code = attrs[:code] || ""

   nid_attr = name_by_attrs(attrs)
   html = block_code(code, language)
   html.sub(%(class="highlight"), %(class="highlight"#{nid_attr}))
end