Class: Ecrire::Markdown::Nodes::CodeBlock
- Inherits:
-
Ecrire::Markdown::Node
- Object
- Ecrire::Markdown::Node
- Ecrire::Markdown::Nodes::CodeBlock
- Defined in:
- lib/ecrire/markdown/nodes/code_block.rb
Instance Attribute Summary
Attributes inherited from Ecrire::Markdown::Node
Instance Method Summary collapse
-
#initialize(language, title, nodes) ⇒ CodeBlock
constructor
A new instance of CodeBlock.
- #to_s ⇒ Object
Constructor Details
#initialize(language, title, nodes) ⇒ CodeBlock
Returns a new instance of CodeBlock.
6 7 8 9 10 |
# File 'lib/ecrire/markdown/nodes/code_block.rb', line 6 def initialize(language, title, nodes) @content = ERB::Util.html_escape(nodes.join("\n")) @title = title @language = language end |
Instance Method Details
#to_s ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ecrire/markdown/nodes/code_block.rb', line 12 def to_s str = "<pre>" str << "<header>#{@title}</header>" str << "<code" unless @language.nil? str << " class='language-#{@language}'>" end str << @content str << "</code></pre>" str end |