Class: TreeHaver::Backends::Commonmarker::Parser
- Inherits:
-
Object
- Object
- TreeHaver::Backends::Commonmarker::Parser
- Defined in:
- lib/tree_haver/backends/commonmarker.rb
Overview
Commonmarker parser wrapper
Instance Attribute Summary collapse
-
#language ⇒ Object
Returns the value of attribute language.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
-
#parse(source) ⇒ Tree
Parse Markdown source code.
-
#parse_string(_old_tree, source) ⇒ Object
Alias for compatibility.
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
122 123 124 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 122 def initialize @language = nil end |
Instance Attribute Details
#language ⇒ Object
Returns the value of attribute language.
120 121 122 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 120 def language @language end |
Instance Method Details
#parse(source) ⇒ Tree
Parse Markdown source code
130 131 132 133 134 135 136 137 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 130 def parse(source) raise "Language not set" unless @language Commonmarker.available? or raise "Commonmarker not available" = @language. || {} doc = ::Commonmarker.parse(source, options: ) Tree.new(doc, source) end |
#parse_string(_old_tree, source) ⇒ Object
Alias for compatibility
140 141 142 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 140 def parse_string(_old_tree, source) parse(source) end |