Class: HTML::Pipeline::RubyMarkup::MarkdownTraverser
- Inherits:
-
Object
- Object
- HTML::Pipeline::RubyMarkup::MarkdownTraverser
- Defined in:
- lib/html/pipeline/ruby_markup/markdown_traverser.rb
Overview
To go through a markdown document. Mainly used to decide if we are in code blocks to decide if we should escape underscored usernames.
Instance Method Summary collapse
- #each ⇒ Object
- #in_codeblock? ⇒ Boolean
-
#initialize(markdown) ⇒ MarkdownTraverser
constructor
A new instance of MarkdownTraverser.
Constructor Details
#initialize(markdown) ⇒ MarkdownTraverser
Returns a new instance of MarkdownTraverser.
9 10 11 12 |
# File 'lib/html/pipeline/ruby_markup/markdown_traverser.rb', line 9 def initialize(markdown) @lines = markdown.dup.lines init_position end |
Instance Method Details
#each ⇒ Object
14 15 16 17 18 19 |
# File 'lib/html/pipeline/ruby_markup/markdown_traverser.rb', line 14 def each lines.each do |line| update_position(line.include?(CODEBLOCK_MARKER)) yield(line) end end |
#in_codeblock? ⇒ Boolean
21 22 23 |
# File 'lib/html/pipeline/ruby_markup/markdown_traverser.rb', line 21 def in_codeblock? prev == true && current == false end |