Class: Asciidoctor::Html5s::AttachedColistTreeprocessor
- Inherits:
-
Extensions::Treeprocessor
- Object
- Extensions::Treeprocessor
- Asciidoctor::Html5s::AttachedColistTreeprocessor
- Defined in:
- lib/asciidoctor/html5s/attached_colist_treeprocessor.rb
Overview
This extension moves every callout list immediately following listing block to instance variable @html5s_colist inside the listing block. The aim is to render callout list as part of the corresponding listing.
Instance Method Summary collapse
Instance Method Details
#process(document) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/asciidoctor/html5s/attached_colist_treeprocessor.rb', line 11 def process(document) document.find_by(context: :colist) do |colist| blocks = colist.parent.blocks colist_idx = blocks.find_index(colist) prev_block = blocks[colist_idx - 1] if colist_idx if prev_block && prev_block.node_name == 'listing' prev_block.instance_variable_set(:@html5s_colist, colist) # XXX: This mutates node's blocks list! # :empty is our special block type that just outputs nothing. blocks[colist_idx] = create_block(colist.parent, :empty, '', {}) end end end |