Class: NumberingVisitor
- Defined in:
- lib/jay_flavored_markdown/markdown_converter.rb
Constant Summary
Constants inherited from Visitor
Instance Method Summary collapse
-
#initialize ⇒ NumberingVisitor
constructor
A new instance of NumberingVisitor.
- #visit_header(el) ⇒ Object
- #visit_li(el) ⇒ Object
- #visit_ol(el) ⇒ Object
Methods inherited from Visitor
Constructor Details
#initialize ⇒ NumberingVisitor
Returns a new instance of NumberingVisitor.
309 310 311 312 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 309 def initialize @label_counter = LeveledCounter.create(:item) @section_counter = SectionCounter.create(:section) end |
Instance Method Details
#visit_header(el) ⇒ Object
333 334 335 336 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 333 def visit_header(el) @section_counter = @section_counter.set_level(el.[:level]) el.value = @section_counter end |
#visit_li(el) ⇒ Object
322 323 324 325 326 327 328 329 330 331 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 322 def visit_li(el) if el.parent.type == :ol @label_counter = @label_counter.next el.value = @label_counter el.attr[:class] = "bullet-list-item" end el.children.each do |child| traverse(child) end end |
#visit_ol(el) ⇒ Object
314 315 316 317 318 319 320 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 314 def visit_ol(el) enter_ol(el) el.children.each do |child| traverse(child) end exit_ol(el) end |