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.
146 147 148 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 146 def initialize @language = nil end |
Instance Attribute Details
#language ⇒ Object
Returns the value of attribute language.
144 145 146 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 144 def language @language end |
Instance Method Details
#parse(source) ⇒ Tree
Parse Markdown source code
154 155 156 157 158 159 160 161 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 154 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
164 165 166 |
# File 'lib/tree_haver/backends/commonmarker.rb', line 164 def parse_string(_old_tree, source) parse(source) end |