Class: NanDoc::Filters::FenceDispatcher
- Inherits:
-
Object
- Object
- NanDoc::Filters::FenceDispatcher
- Defined in:
- lib/nandoc/filters/builtin-tags/fence-dispatcher.rb
Constant Summary collapse
- Re =
%r< (.*?) ^((?:[ ]|\t)*)((?:[a-z]|[ ])+):(?:[ ]|\t)*\n \2~~~(?:[ ]|\t)*\n (.*?)\n \2~~~(?:[ ]|\t)*\n >mx
Class Attribute Summary collapse
-
.fences ⇒ Object
readonly
Returns the value of attribute fences.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.fences ⇒ Object (readonly)
Returns the value of attribute fences.
20 21 22 |
# File 'lib/nandoc/filters/builtin-tags/fence-dispatcher.rb', line 20 def fences @fences end |
Class Method Details
.=~(item_content) ⇒ Object
14 15 16 |
# File 'lib/nandoc/filters/builtin-tags/fence-dispatcher.rb', line 14 def =~ item_content Re =~ item_content end |
.register(fent) ⇒ Object
17 18 19 |
# File 'lib/nandoc/filters/builtin-tags/fence-dispatcher.rb', line 17 def register fent @fences.push fent end |
Instance Method Details
#run(item_content) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nandoc/filters/builtin-tags/fence-dispatcher.rb', line 22 def run item_content scn = StringScanner.new(item_content) out = NanDoc::Html::Tags.new while (match = scn.scan_until(Re)) Re =~ match or fail("internal parse fail :(") noparse, indent, label, content = $~.captures fence_cls = self.class.fences.detect{ |fent| fent =~ label } if ! fence_cls # silently fail on unidentified blocks for now, pass them thru out.push_raw $~[0] else out.push_raw noparse fence_tag = fence_cls.new fence_tag.run(out, indent, label, content) end end out.push_raw scn.rest html = out.to_html html end |