Class: FujiMarkdown::Processor
- Inherits:
-
Object
- Object
- FujiMarkdown::Processor
- Defined in:
- lib/fuji_markdown/processor.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#postprocessors ⇒ Object
readonly
Returns the value of attribute postprocessors.
-
#preprocessors ⇒ Object
readonly
Returns the value of attribute preprocessors.
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#initialize(preprocessors: [], parser: CommonMarker, postprocessors: [], renderer: CommonMarker::HtmlRenderer.new) ⇒ Processor
constructor
A new instance of Processor.
- #parse(text) ⇒ Object
- #render(text) ⇒ Object
Constructor Details
#initialize(preprocessors: [], parser: CommonMarker, postprocessors: [], renderer: CommonMarker::HtmlRenderer.new) ⇒ Processor
Returns a new instance of Processor.
5 6 7 8 9 10 |
# File 'lib/fuji_markdown/processor.rb', line 5 def initialize(preprocessors: [], parser: CommonMarker, postprocessors: [], renderer: CommonMarker::HtmlRenderer.new) @preprocessors = preprocessors @parser = parser @postprocessors = postprocessors @renderer = renderer end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
3 4 5 |
# File 'lib/fuji_markdown/processor.rb', line 3 def parser @parser end |
#postprocessors ⇒ Object (readonly)
Returns the value of attribute postprocessors.
3 4 5 |
# File 'lib/fuji_markdown/processor.rb', line 3 def postprocessors @postprocessors end |
#preprocessors ⇒ Object (readonly)
Returns the value of attribute preprocessors.
3 4 5 |
# File 'lib/fuji_markdown/processor.rb', line 3 def preprocessors @preprocessors end |
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
3 4 5 |
# File 'lib/fuji_markdown/processor.rb', line 3 def renderer @renderer end |
Instance Method Details
#parse(text) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/fuji_markdown/processor.rb', line 12 def parse(text) processed_text = text.dup preprocessors.each do |preprocessor| preprocessor.call(processed_text) end parser.render_doc(processed_text) end |
#render(text) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/fuji_markdown/processor.rb', line 22 def render(text) doc = parse(text) postprocessors.each do |postprocessor| postprocessor.call(doc) end renderer.render(doc) end |