class Kramdown::Parser::Kramdown
Constants
- STRIKETHROUGH_DELIMITER
- STRIKETHROUGH_DELIMITER_PATTERN
Public Instance Methods
configure_parser()
click to toggle source
# File lib/rabbit/parser/markdown.rb, line 36 def configure_parser @span_parsers.unshift(:strikethrough) position = @block_parsers.index(:codeblock_fenced) @block_parsers.insert(position, :codeblock_fenced_gfm) configure_parser_raw end
Also aliased as: configure_parser_raw
handle_extension(name, opts, body, type, line_no=nil)
click to toggle source
# File lib/rabbit/parser/markdown.rb, line 10 def handle_extension(name, opts, body, type, line_no=nil) return true if handle_extension_raw(name, opts, body, type, line_no) element = Element.new(name.to_sym, nil, opts, :category => type, :location => line_no) if body root, warnings = self.class.parse(body, @options) fix_location(root, line_no) if type == :span p_element = root.children.first p_element.children.each do |sub_element| element.children << sub_element end else root.children.each do |sub_element| element.children << sub_element end end end @tree.children << element true end
Also aliased as: handle_extension_raw
parse_codeblock_fenced_gfm()
click to toggle source
# File lib/rabbit/parser/markdown.rb, line 73 def parse_codeblock_fenced_gfm original_match = self.class::FENCED_CODEBLOCK_MATCH begin self.class.send(:remove_const, :FENCED_CODEBLOCK_MATCH) self.class.const_set(:FENCED_CODEBLOCK_MATCH, GFM::FENCED_CODEBLOCK_MATCH) parse_codeblock_fenced ensure self.class.send(:remove_const, :FENCED_CODEBLOCK_MATCH) self.class.const_set(:FENCED_CODEBLOCK_MATCH, original_match) end end
parse_strikethrough()
click to toggle source
# File lib/rabbit/parser/markdown.rb, line 47 def parse_strikethrough start_line_number = @src.current_line_number delimiter = @src.scan(STRIKETHROUGH_DELIMITER_PATTERN) saved_pos = @src.save_pos text = @src.scan_until(STRIKETHROUGH_DELIMITER_PATTERN) if text text = text.sub(/#{STRIKETHROUGH_DELIMITER_PATTERN}\Z/, "") @tree.children << Element.new(:strikethrough, text, nil, :location => start_line_number) else @src.revert_pos(saved_pos) add_text(delimiter) end end
Private Instance Methods
fix_location(element, base_location)
click to toggle source
# File lib/rabbit/parser/markdown.rb, line 87 def fix_location(element, base_location) return unless element.options.key?(:location) element.options[:location] += base_location - 1 element.children.each do |sub_element| fix_location(sub_element, base_location) end end