Class: Kramdown::Parser::GFM
- Inherits:
-
Object
- Object
- Kramdown::Parser::GFM
- Defined in:
- lib/bridgetown-core/kramdown/parser/gfm.rb
Constant Summary collapse
- MARK_DELIMITER =
%r{(==|::)+}
- MARK_MATCH =
%r{#{MARK_DELIMITER}(?!\s|=|:).*?[^\s=:]#{MARK_DELIMITER}}m
Instance Method Summary collapse
-
#_old_initialize ⇒ Object
Monkey-patch GFM initializer to add our new mark parser.
-
#initialize(source, options) ⇒ GFM
constructor
A new instance of GFM.
- #parse_mark ⇒ Object
Constructor Details
#initialize(source, options) ⇒ GFM
Returns a new instance of GFM.
13 14 15 16 |
# File 'lib/bridgetown-core/kramdown/parser/gfm.rb', line 13 def initialize(source, ) _old_initialize(source, ) @span_parsers << :mark if @options[:mark_highlighting] end |
Instance Method Details
#_old_initialize ⇒ Object
Monkey-patch GFM initializer to add our new mark parser
12 |
# File 'lib/bridgetown-core/kramdown/parser/gfm.rb', line 12 alias_method :_old_initialize, :initialize |
#parse_mark ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bridgetown-core/kramdown/parser/gfm.rb', line 18 def parse_mark line_number = @src.current_line_number @src.pos += @src.matched_size el = Element.new(:html_element, "mark", {}, category: :span, line: line_number) @tree.children << el env = save_env reset_env(src: Kramdown::Utils::StringScanner.new(@src.matched[2..-3], line_number), text_type: :text) parse_spans(el) restore_env(env) el end |