Class: Kramdown::Parser::Hierogloss
- Inherits:
-
Kramdown
- Object
- Kramdown
- Kramdown::Parser::Hierogloss
- Defined in:
- lib/kramdown/parser/hierogloss.rb
Overview
Parses an extended Kramdown syntax with support for inline glosses. Everything in this class is internal.
Constant Summary collapse
- TRANSLIT_START =
/{.*?}/- GLOSS_START =
/^(H|L|G|T):/- GLOSS_MATCH =
/((^(H|L|G|T):.*)\r?\n)*/
Instance Method Summary collapse
-
#initialize(source, options) ⇒ Hierogloss
constructor
A new instance of Hierogloss.
- #parse_gloss ⇒ Object
- #parse_translit ⇒ Object
Constructor Details
#initialize(source, options) ⇒ Hierogloss
Returns a new instance of Hierogloss.
6 7 8 9 10 |
# File 'lib/kramdown/parser/hierogloss.rb', line 6 def initialize(source, ) super @span_parsers.unshift(:translit) @block_parsers.unshift(:gloss) end |
Instance Method Details
#parse_gloss ⇒ Object
27 28 29 30 31 32 |
# File 'lib/kramdown/parser/hierogloss.rb', line 27 def parse_gloss start_line_number = @src.current_line_number data = @src.scan(self.class::GLOSS_MATCH) @tree.children.concat(::Hierogloss::Gloss.new(data).to_kramdown) true end |
#parse_translit ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/kramdown/parser/hierogloss.rb', line 14 def parse_translit @src.pos += @src.matched_size mdc = @src.matched[1..-2] em = Element.new(:em, nil, 'class' => 'hgls-l') em.children << Element.new(:text, ::Hierogloss::TransliterationRow.fancy(mdc)) @tree.children << em end |