Class: ReferenceVisitor
- Defined in:
- lib/jay_flavored_markdown/markdown_converter.rb
Constant Summary
Constants inherited from Visitor
Instance Attribute Summary collapse
-
#item_table ⇒ Object
readonly
Returns the value of attribute item_table.
-
#section_table ⇒ Object
readonly
Returns the value of attribute section_table.
-
#xref_table ⇒ Object
readonly
Returns the value of attribute xref_table.
Instance Method Summary collapse
-
#initialize ⇒ ReferenceVisitor
constructor
A new instance of ReferenceVisitor.
- #visit_header(el) ⇒ Object
- #visit_label(el) ⇒ Object
- #visit_li(el) ⇒ Object
Methods inherited from Visitor
Constructor Details
#initialize ⇒ ReferenceVisitor
350 351 352 353 354 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 350 def initialize @xref_table = {} @item_table = [] @section_table = [] end |
Instance Attribute Details
#item_table ⇒ Object (readonly)
Returns the value of attribute item_table.
355 356 357 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 355 def item_table @item_table end |
#section_table ⇒ Object (readonly)
Returns the value of attribute section_table.
355 356 357 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 355 def section_table @section_table end |
#xref_table ⇒ Object (readonly)
Returns the value of attribute xref_table.
355 356 357 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 355 def xref_table @xref_table end |
Instance Method Details
#visit_header(el) ⇒ Object
375 376 377 378 379 380 381 382 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 375 def visit_header(el) el.[:relative_position] = @section_table.size @section_table << el el.children.each do |child| traverse(child) end return el end |
#visit_label(el) ⇒ Object
357 358 359 360 361 362 363 364 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 357 def visit_label(el) ref = el.find_first_ancestor(:header) || el.find_first_ancestor(:li) @xref_table[el.value] = ref.value if ref.value el.children.each do |child| traverse(child) end return el end |
#visit_li(el) ⇒ Object
366 367 368 369 370 371 372 373 |
# File 'lib/jay_flavored_markdown/markdown_converter.rb', line 366 def visit_li(el) el.[:relative_position] = @item_table.size @item_table << el el.children.each do |child| traverse(child) end return el end |