Class: Kramdown::Parser::Kramdown

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit/parser/markdown.rb

Instance Method Summary collapse

Instance Method Details

#configure_parserObject



37
38
39
40
41
42
# File 'lib/rabbit/parser/markdown.rb', line 37

def configure_parser
  position = @block_parsers.index(:codeblock_fenced)
  @block_parsers.insert(position, :codeblock_fenced_gfm)

  configure_parser_raw
end

#configure_parser_rawObject



36
# File 'lib/rabbit/parser/markdown.rb', line 36

alias_method :configure_parser_raw, :configure_parser

#handle_extension(name, opts, body, type, line_no = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rabbit/parser/markdown.rb', line 11

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

#handle_extension_rawObject



10
# File 'lib/rabbit/parser/markdown.rb', line 10

alias_method :handle_extension_raw, :handle_extension

#parse_codeblock_fenced_gfmObject



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rabbit/parser/markdown.rb', line 46

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