Class: Kramdown::Parser::RFC2629Kramdown
- Defined in:
- lib/kramdown-rfc2629.rb
Constant Summary collapse
- XREF_START =
/\{\{(.*?)\}\}/u
- IREF_START =
/\(\(\((.*?)\)\)\)/u
Instance Method Summary collapse
-
#initialize(*doc) ⇒ RFC2629Kramdown
constructor
A new instance of RFC2629Kramdown.
-
#parse_iref ⇒ Object
Introduce new (((target))) syntax for irefs.
-
#parse_xref ⇒ Object
Introduce new {target} syntax for empty xrefs, which would otherwise be an ugly ![!](target) or ![ ](target) (I’d rather use [[target]], but that somehow clashes with links.).
Constructor Details
#initialize(*doc) ⇒ RFC2629Kramdown
Returns a new instance of RFC2629Kramdown.
34 35 36 37 38 |
# File 'lib/kramdown-rfc2629.rb', line 34 def initialize(*doc) super @span_parsers.unshift(:xref) @span_parsers.unshift(:iref) end |
Instance Method Details
#parse_iref ⇒ Object
Introduce new (((target))) syntax for irefs
57 58 59 60 61 62 |
# File 'lib/kramdown-rfc2629.rb', line 57 def parse_iref @src.pos += @src.matched_size href = @src[1] el = Element.new(:iref, nil, {'target' => href}) # XXX @tree.children << el end |
#parse_xref ⇒ Object
Introduce new {target} syntax for empty xrefs, which would otherwise be an ugly ![!](target) or ![ ](target) (I’d rather use [[target]], but that somehow clashes with links.)
45 46 47 48 49 50 51 |
# File 'lib/kramdown-rfc2629.rb', line 45 def parse_xref @src.pos += @src.matched_size href = @src[1] href = href.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number el = Element.new(:xref, nil, {'target' => href}) @tree.children << el end |