kramdown 1.17.0 → 2.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kramdown might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/CONTRIBUTERS +4 -2
 - data/VERSION +1 -1
 - data/bin/kramdown +13 -14
 - data/lib/kramdown.rb +2 -2
 - data/lib/kramdown/converter.rb +6 -7
 - data/lib/kramdown/converter/base.rb +18 -29
 - data/lib/kramdown/converter/hash_ast.rb +4 -4
 - data/lib/kramdown/converter/html.rb +82 -67
 - data/lib/kramdown/converter/kramdown.rb +83 -78
 - data/lib/kramdown/converter/latex.rb +53 -47
 - data/lib/kramdown/converter/man.rb +22 -25
 - data/lib/kramdown/converter/math_engine/mathjax.rb +10 -10
 - data/lib/kramdown/converter/remove_html_tags.rb +2 -2
 - data/lib/kramdown/converter/syntax_highlighter.rb +2 -2
 - data/lib/kramdown/converter/syntax_highlighter/minted.rb +2 -2
 - data/lib/kramdown/converter/syntax_highlighter/rouge.rb +5 -5
 - data/lib/kramdown/converter/toc.rb +5 -5
 - data/lib/kramdown/document.rb +9 -11
 - data/lib/kramdown/element.rb +11 -9
 - data/lib/kramdown/error.rb +2 -2
 - data/lib/kramdown/options.rb +258 -384
 - data/lib/kramdown/parser.rb +2 -3
 - data/lib/kramdown/parser/base.rb +7 -6
 - data/lib/kramdown/parser/html.rb +103 -95
 - data/lib/kramdown/parser/kramdown.rb +32 -36
 - data/lib/kramdown/parser/kramdown/abbreviation.rb +13 -10
 - data/lib/kramdown/parser/kramdown/autolink.rb +3 -3
 - data/lib/kramdown/parser/kramdown/blank_line.rb +2 -2
 - data/lib/kramdown/parser/kramdown/block_boundary.rb +2 -2
 - data/lib/kramdown/parser/kramdown/blockquote.rb +4 -5
 - data/lib/kramdown/parser/kramdown/codeblock.rb +4 -5
 - data/lib/kramdown/parser/kramdown/codespan.rb +5 -5
 - data/lib/kramdown/parser/kramdown/emphasis.rb +6 -6
 - data/lib/kramdown/parser/kramdown/eob.rb +2 -2
 - data/lib/kramdown/parser/kramdown/escaped_chars.rb +2 -2
 - data/lib/kramdown/parser/kramdown/extensions.rb +31 -26
 - data/lib/kramdown/parser/kramdown/footnote.rb +7 -6
 - data/lib/kramdown/parser/kramdown/header.rb +6 -6
 - data/lib/kramdown/parser/kramdown/horizontal_rule.rb +3 -3
 - data/lib/kramdown/parser/kramdown/html.rb +31 -26
 - data/lib/kramdown/parser/kramdown/html_entity.rb +6 -5
 - data/lib/kramdown/parser/kramdown/line_break.rb +3 -3
 - data/lib/kramdown/parser/kramdown/link.rb +13 -11
 - data/lib/kramdown/parser/kramdown/list.rb +38 -40
 - data/lib/kramdown/parser/kramdown/math.rb +4 -5
 - data/lib/kramdown/parser/kramdown/paragraph.rb +5 -5
 - data/lib/kramdown/parser/kramdown/smart_quotes.rb +23 -23
 - data/lib/kramdown/parser/kramdown/table.rb +18 -17
 - data/lib/kramdown/parser/kramdown/typographic_symbol.rb +8 -8
 - data/lib/kramdown/parser/markdown.rb +9 -8
 - data/lib/kramdown/utils.rb +5 -6
 - data/lib/kramdown/utils/configurable.rb +7 -6
 - data/lib/kramdown/utils/entities.rb +286 -289
 - data/lib/kramdown/utils/html.rb +10 -12
 - data/lib/kramdown/utils/lru_cache.rb +3 -2
 - data/lib/kramdown/utils/string_scanner.rb +2 -3
 - data/lib/kramdown/utils/unidecoder.rb +8 -6
 - data/lib/kramdown/version.rb +3 -3
 - data/man/man1/kramdown.1 +3 -107
 - data/test/run_tests.rb +6 -6
 - data/test/test_files.rb +122 -298
 - data/test/test_location.rb +8 -30
 - data/test/test_string_scanner_kramdown.rb +6 -9
 - data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -6
 - data/test/testcases/block/06_codeblock/highlighting.html +5 -6
 - data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options +1 -1
 - data/test/testcases/block/07_horizontal_rule/error.html +2 -2
 - data/test/testcases/block/09_html/html5_attributes.html +2 -0
 - data/test/testcases/block/09_html/html5_attributes.text +2 -0
 - data/test/testcases/block/09_html/html_to_native/typography.html +1 -1
 - data/test/testcases/block/09_html/simple.html +1 -1
 - data/test/testcases/block/12_extension/options3.html +7 -6
 - data/test/testcases/block/12_extension/options3.text +2 -2
 - data/test/testcases/span/01_link/inline.html +1 -1
 - data/test/testcases/span/01_link/reference.html +3 -3
 - data/test/testcases/span/03_codespan/highlighting.html +1 -1
 - data/test/testcases/span/text_substitutions/entities_as_char.html +1 -1
 - metadata +5 -234
 - data/Rakefile +0 -341
 - data/benchmark/benchmark.rb +0 -43
 - data/benchmark/benchmark.sh +0 -74
 - data/benchmark/generate_data.rb +0 -119
 - data/benchmark/mdbasics.text +0 -306
 - data/benchmark/mdsyntax.text +0 -888
 - data/benchmark/testing.sh +0 -12
 - data/benchmark/timing.sh +0 -10
 - data/doc/_design.scss +0 -441
 - data/doc/bg.png +0 -0
 - data/doc/default.scss +0 -217
 - data/doc/default.template +0 -62
 - data/doc/documentation.page +0 -84
 - data/doc/documentation.template +0 -36
 - data/doc/index.page +0 -113
 - data/doc/installation.page +0 -88
 - data/doc/links.markdown +0 -6
 - data/doc/metainfo +0 -13
 - data/doc/news.feed +0 -9
 - data/doc/news.page +0 -29
 - data/doc/options.page +0 -49
 - data/doc/quickref.page +0 -603
 - data/doc/sidebar.template +0 -22
 - data/doc/sitemap.sitemap +0 -5
 - data/doc/syntax.page +0 -1799
 - data/doc/tests.page +0 -104
 - data/doc/virtual +0 -14
 - data/lib/kramdown/converter/math_engine/itex2mml.rb +0 -39
 - data/lib/kramdown/converter/math_engine/katex.rb +0 -35
 - data/lib/kramdown/converter/math_engine/mathjaxnode.rb +0 -56
 - data/lib/kramdown/converter/math_engine/ritex.rb +0 -38
 - data/lib/kramdown/converter/math_engine/sskatex.rb +0 -97
 - data/lib/kramdown/converter/pdf.rb +0 -625
 - data/lib/kramdown/converter/syntax_highlighter/coderay.rb +0 -81
 - data/lib/kramdown/parser/gfm.rb +0 -188
 - data/lib/kramdown/utils/ordered_hash.rb +0 -18
 - data/setup.rb +0 -1585
 - data/test/testcases/block/07_horizontal_rule/error.html.19 +0 -7
 - data/test/testcases/block/09_html/html_to_native/typography.html.19 +0 -1
 - data/test/testcases/block/09_html/simple.html.19 +0 -60
 - data/test/testcases/block/15_math/itex2mml.html +0 -1
 - data/test/testcases/block/15_math/itex2mml.options +0 -1
 - data/test/testcases/block/15_math/itex2mml.text +0 -1
 - data/test/testcases/block/15_math/katex.html.19 +0 -2
 - data/test/testcases/block/15_math/katex.options +0 -1
 - data/test/testcases/block/15_math/katex.text +0 -2
 - data/test/testcases/block/15_math/mathjaxnode.html.19 +0 -27
 - data/test/testcases/block/15_math/mathjaxnode.options +0 -1
 - data/test/testcases/block/15_math/mathjaxnode.text +0 -1
 - data/test/testcases/block/15_math/mathjaxnode_notexhints.html.19 +0 -23
 - data/test/testcases/block/15_math/mathjaxnode_notexhints.options +0 -3
 - data/test/testcases/block/15_math/mathjaxnode_notexhints.text +0 -1
 - data/test/testcases/block/15_math/mathjaxnode_semantics.html.19 +0 -32
 - data/test/testcases/block/15_math/mathjaxnode_semantics.options +0 -3
 - data/test/testcases/block/15_math/mathjaxnode_semantics.text +0 -1
 - data/test/testcases/block/15_math/ritex.html +0 -1
 - data/test/testcases/block/15_math/ritex.options +0 -1
 - data/test/testcases/block/15_math/ritex.text +0 -1
 - data/test/testcases/block/15_math/sskatex.html.19 +0 -2
 - data/test/testcases/block/15_math/sskatex.options +0 -1
 - data/test/testcases/block/15_math/sskatex.text +0 -2
 - data/test/testcases/span/01_link/inline.html.19 +0 -46
 - data/test/testcases/span/01_link/reference.html.19 +0 -37
 - data/test/testcases/span/math/itex2mml.html +0 -1
 - data/test/testcases/span/math/itex2mml.options +0 -1
 - data/test/testcases/span/math/itex2mml.text +0 -1
 - data/test/testcases/span/math/katex.html.19 +0 -1
 - data/test/testcases/span/math/katex.options +0 -1
 - data/test/testcases/span/math/katex.text +0 -1
 - data/test/testcases/span/math/mathjaxnode.html.19 +0 -27
 - data/test/testcases/span/math/mathjaxnode.options +0 -1
 - data/test/testcases/span/math/mathjaxnode.text +0 -1
 - data/test/testcases/span/math/ritex.html +0 -1
 - data/test/testcases/span/math/ritex.options +0 -1
 - data/test/testcases/span/math/ritex.text +0 -1
 - data/test/testcases/span/math/sskatex.html.19 +0 -1
 - data/test/testcases/span/math/sskatex.options +0 -1
 - data/test/testcases/span/math/sskatex.text +0 -1
 - data/test/testcases/span/text_substitutions/entities_as_char.html.19 +0 -1
 - data/test/testcases_gfm/atx_header.html +0 -3
 - data/test/testcases_gfm/atx_header.text +0 -3
 - data/test/testcases_gfm/backticks_disable_highlighting.html +0 -2
 - data/test/testcases_gfm/backticks_disable_highlighting.options +0 -1
 - data/test/testcases_gfm/backticks_disable_highlighting.text +0 -3
 - data/test/testcases_gfm/backticks_syntax.html +0 -20
 - data/test/testcases_gfm/backticks_syntax.text +0 -19
 - data/test/testcases_gfm/codeblock_fenced.html +0 -20
 - data/test/testcases_gfm/codeblock_fenced.options +0 -1
 - data/test/testcases_gfm/codeblock_fenced.text +0 -21
 - data/test/testcases_gfm/hard_line_breaks.html +0 -3
 - data/test/testcases_gfm/hard_line_breaks.text +0 -3
 - data/test/testcases_gfm/hard_line_breaks_off.html +0 -2
 - data/test/testcases_gfm/hard_line_breaks_off.options +0 -1
 - data/test/testcases_gfm/hard_line_breaks_off.text +0 -2
 - data/test/testcases_gfm/header_ids.html +0 -27
 - data/test/testcases_gfm/header_ids.html.19 +0 -27
 - data/test/testcases_gfm/header_ids.options +0 -1
 - data/test/testcases_gfm/header_ids.text +0 -27
 - data/test/testcases_gfm/header_ids_with_prefix.html +0 -3
 - data/test/testcases_gfm/header_ids_with_prefix.options +0 -2
 - data/test/testcases_gfm/header_ids_with_prefix.text +0 -3
 - data/test/testcases_gfm/no_typographic.html +0 -3
 - data/test/testcases_gfm/no_typographic.html.19 +0 -3
 - data/test/testcases_gfm/no_typographic.options +0 -1
 - data/test/testcases_gfm/no_typographic.text +0 -3
 - data/test/testcases_gfm/paragraph_end-disabled.html +0 -31
 - data/test/testcases_gfm/paragraph_end-disabled.options +0 -1
 - data/test/testcases_gfm/paragraph_end-disabled.text +0 -27
 - data/test/testcases_gfm/paragraph_end.html +0 -38
 - data/test/testcases_gfm/paragraph_end.text +0 -27
 - data/test/testcases_gfm/strikethrough.html +0 -27
 - data/test/testcases_gfm/strikethrough.html.19 +0 -27
 - data/test/testcases_gfm/strikethrough.text +0 -27
 - data/test/testcases_gfm/task_list.html +0 -40
 - data/test/testcases_gfm/task_list.text +0 -26
 - data/test/testcases_gfm/two_para_hard_line_breaks.html +0 -4
 - data/test/testcases_gfm/two_para_hard_line_breaks.text +0 -4
 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -11,8 +11,8 @@ require 'strscan' 
     | 
|
| 
       11 
11 
     | 
    
         
             
            require 'stringio'
         
     | 
| 
       12 
12 
     | 
    
         
             
            require 'kramdown/parser'
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            #TODO: use [[:alpha:]] in all regexp to allow parsing of international values in 1.9.1
         
     | 
| 
       15 
     | 
    
         
            -
            #NOTE: use @src.pre_match only before other check/match?/... operations, otherwise the content is changed
         
     | 
| 
      
 14 
     | 
    
         
            +
            # TODO: use [[:alpha:]] in all regexp to allow parsing of international values in 1.9.1
         
     | 
| 
      
 15 
     | 
    
         
            +
            # NOTE: use @src.pre_match only before other check/match?/... operations, otherwise the content is changed
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            module Kramdown
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
         @@ -74,15 +74,14 @@ module Kramdown 
     | 
|
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
                    @block_parsers = [:blank_line, :codeblock, :codeblock_fenced, :blockquote, :atx_header,
         
     | 
| 
       76 
76 
     | 
    
         
             
                                      :horizontal_rule, :list, :definition_list, :block_html, :setext_header,
         
     | 
| 
       77 
     | 
    
         
            -
                                      :block_math, :table, :footnote_definition, :link_definition, 
     | 
| 
       78 
     | 
    
         
            -
                                      :block_extensions, :eob_marker, :paragraph]
         
     | 
| 
       79 
     | 
    
         
            -
                    @span_parsers =  [:emphasis, :codespan, :autolink, :span_html, :footnote_marker, :link, 
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 77 
     | 
    
         
            +
                                      :block_math, :table, :footnote_definition, :link_definition,
         
     | 
| 
      
 78 
     | 
    
         
            +
                                      :abbrev_definition, :block_extensions, :eob_marker, :paragraph]
         
     | 
| 
      
 79 
     | 
    
         
            +
                    @span_parsers =  [:emphasis, :codespan, :autolink, :span_html, :footnote_marker, :link,
         
     | 
| 
      
 80 
     | 
    
         
            +
                                      :smart_quotes, :inline_math, :span_extensions, :html_entity,
         
     | 
| 
      
 81 
     | 
    
         
            +
                                      :typographic_syms, :line_break, :escaped_chars]
         
     | 
| 
       82 
82 
     | 
    
         
             
                  end
         
     | 
| 
       83 
83 
     | 
    
         
             
                  private_class_method(:new, :allocate)
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
85 
     | 
    
         
             
                  # The source string provided on initialization is parsed into the @root element.
         
     | 
| 
       87 
86 
     | 
    
         
             
                  def parse
         
     | 
| 
       88 
87 
     | 
    
         
             
                    configure_parser
         
     | 
| 
         @@ -90,7 +89,7 @@ module Kramdown 
     | 
|
| 
       90 
89 
     | 
    
         
             
                    update_tree(@root)
         
     | 
| 
       91 
90 
     | 
    
         
             
                    correct_abbreviations_attributes
         
     | 
| 
       92 
91 
     | 
    
         
             
                    replace_abbreviations(@root)
         
     | 
| 
       93 
     | 
    
         
            -
                    @footnotes.each do | 
     | 
| 
      
 92 
     | 
    
         
            +
                    @footnotes.each do |_name, data|
         
     | 
| 
       94 
93 
     | 
    
         
             
                      update_tree(data[:content])
         
     | 
| 
       95 
94 
     | 
    
         
             
                      replace_abbreviations(data[:content])
         
     | 
| 
       96 
95 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -101,9 +100,7 @@ module Kramdown 
     | 
|
| 
       101 
100 
     | 
    
         
             
                    end
         
     | 
| 
       102 
101 
     | 
    
         
             
                  end
         
     | 
| 
       103 
102 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                  #######
         
     | 
| 
       105 
103 
     | 
    
         
             
                  protected
         
     | 
| 
       106 
     | 
    
         
            -
                  #######
         
     | 
| 
       107 
104 
     | 
    
         | 
| 
       108 
105 
     | 
    
         
             
                  # :doc:
         
     | 
| 
       109 
106 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -113,7 +110,7 @@ module Kramdown 
     | 
|
| 
       113 
110 
     | 
    
         
             
                  # The parameter +link_defs+ is a hash where the keys are possibly unnormalized link IDs and
         
     | 
| 
       114 
111 
     | 
    
         
             
                  # the values are two element arrays consisting of the link target and a title (can be +nil+).
         
     | 
| 
       115 
112 
     | 
    
         
             
                  def update_link_definitions(link_defs)
         
     | 
| 
       116 
     | 
    
         
            -
                    link_defs.each {|k,v| @link_defs[normalize_link_id(k)] = v}
         
     | 
| 
      
 113 
     | 
    
         
            +
                    link_defs.each {|k, v| @link_defs[normalize_link_id(k)] = v }
         
     | 
| 
       117 
114 
     | 
    
         
             
                  end
         
     | 
| 
       118 
115 
     | 
    
         | 
| 
       119 
116 
     | 
    
         
             
                  # Adapt the object to allow parsing like specified in the options.
         
     | 
| 
         @@ -131,7 +128,7 @@ module Kramdown 
     | 
|
| 
       131 
128 
     | 
    
         | 
| 
       132 
129 
     | 
    
         
             
                  # Create the needed span parser regexps.
         
     | 
| 
       133 
130 
     | 
    
         
             
                  def span_parser_regexps(parsers = @span_parsers)
         
     | 
| 
       134 
     | 
    
         
            -
                    span_start = /#{parsers.map {|name| @parsers[name].span_start}.join('|')}/
         
     | 
| 
      
 131 
     | 
    
         
            +
                    span_start = /#{parsers.map {|name| @parsers[name].span_start }.join('|')}/
         
     | 
| 
       135 
132 
     | 
    
         
             
                    [span_start, /(?=#{span_start})/]
         
     | 
| 
       136 
133 
     | 
    
         
             
                  end
         
     | 
| 
       137 
134 
     | 
    
         | 
| 
         @@ -142,7 +139,7 @@ module Kramdown 
     | 
|
| 
       142 
139 
     | 
    
         
             
                    @src = (text.nil? ? @src : ::Kramdown::Utils::StringScanner.new(text, el.options[:location]))
         
     | 
| 
       143 
140 
     | 
    
         | 
| 
       144 
141 
     | 
    
         
             
                    status = catch(:stop_block_parsing) do
         
     | 
| 
       145 
     | 
    
         
            -
                       
     | 
| 
      
 142 
     | 
    
         
            +
                      until @src.eos?
         
     | 
| 
       146 
143 
     | 
    
         
             
                        @block_parsers.any? do |name|
         
     | 
| 
       147 
144 
     | 
    
         
             
                          if @src.check(@parsers[name].start_re)
         
     | 
| 
       148 
145 
     | 
    
         
             
                            send(@parsers[name].method)
         
     | 
| 
         @@ -167,8 +164,8 @@ module Kramdown 
     | 
|
| 
       167 
164 
     | 
    
         
             
                    element.children.map! do |child|
         
     | 
| 
       168 
165 
     | 
    
         
             
                      if child.type == :raw_text
         
     | 
| 
       169 
166 
     | 
    
         
             
                        last_blank = nil
         
     | 
| 
       170 
     | 
    
         
            -
                        reset_env(: 
     | 
| 
       171 
     | 
    
         
            -
                                  : 
     | 
| 
      
 167 
     | 
    
         
            +
                        reset_env(src: ::Kramdown::Utils::StringScanner.new(child.value, element.options[:location]),
         
     | 
| 
      
 168 
     | 
    
         
            +
                                  text_type: :text)
         
     | 
| 
       172 
169 
     | 
    
         
             
                        parse_spans(child)
         
     | 
| 
       173 
170 
     | 
    
         
             
                        child.children
         
     | 
| 
       174 
171 
     | 
    
         
             
                      elsif child.type == :eob
         
     | 
| 
         @@ -212,12 +209,12 @@ module Kramdown 
     | 
|
| 
       212 
209 
     | 
    
         
             
                    span_start = @span_start
         
     | 
| 
       213 
210 
     | 
    
         
             
                    span_start_re = @span_start_re
         
     | 
| 
       214 
211 
     | 
    
         
             
                    span_start, span_start_re = span_parser_regexps(parsers) if parsers
         
     | 
| 
       215 
     | 
    
         
            -
                    parsers  
     | 
| 
      
 212 
     | 
    
         
            +
                    parsers ||= @span_parsers
         
     | 
| 
       216 
213 
     | 
    
         | 
| 
       217 
214 
     | 
    
         
             
                    used_re = (stop_re.nil? ? span_start_re : /(?=#{Regexp.union(stop_re, span_start)})/)
         
     | 
| 
       218 
215 
     | 
    
         
             
                    stop_re_found = false
         
     | 
| 
       219 
216 
     | 
    
         
             
                    while !@src.eos? && !stop_re_found
         
     | 
| 
       220 
     | 
    
         
            -
                      if result = @src.scan_until(used_re)
         
     | 
| 
      
 217 
     | 
    
         
            +
                      if (result = @src.scan_until(used_re))
         
     | 
| 
       221 
218 
     | 
    
         
             
                        add_text(result)
         
     | 
| 
       222 
219 
     | 
    
         
             
                        if stop_re && @src.check(stop_re)
         
     | 
| 
       223 
220 
     | 
    
         
             
                          stop_re_found = (block_given? ? yield : true)
         
     | 
| 
         @@ -245,7 +242,7 @@ module Kramdown 
     | 
|
| 
       245 
242 
     | 
    
         
             
                  # Reset the current parsing environment. The parameter +env+ can be used to set initial
         
     | 
| 
       246 
243 
     | 
    
         
             
                  # values for one or more environment variables.
         
     | 
| 
       247 
244 
     | 
    
         
             
                  def reset_env(opts = {})
         
     | 
| 
       248 
     | 
    
         
            -
                    opts = {: 
     | 
| 
      
 245 
     | 
    
         
            +
                    opts = {text_type: :raw_text, stack: []}.merge(opts)
         
     | 
| 
       249 
246 
     | 
    
         
             
                    @src = opts[:src]
         
     | 
| 
       250 
247 
     | 
    
         
             
                    @tree = opts[:tree]
         
     | 
| 
       251 
248 
     | 
    
         
             
                    @block_ial = opts[:block_ial]
         
     | 
| 
         @@ -255,24 +252,23 @@ module Kramdown 
     | 
|
| 
       255 
252 
     | 
    
         | 
| 
       256 
253 
     | 
    
         
             
                  # Return the current parsing environment.
         
     | 
| 
       257 
254 
     | 
    
         
             
                  def save_env
         
     | 
| 
       258 
     | 
    
         
            -
                    [@src, @tree, @block_ial, @stack, 
     | 
| 
      
 255 
     | 
    
         
            +
                    [@src, @tree, @block_ial, @stack, @text_type]
         
     | 
| 
       259 
256 
     | 
    
         
             
                  end
         
     | 
| 
       260 
257 
     | 
    
         | 
| 
       261 
258 
     | 
    
         
             
                  # Restore the current parsing environment.
         
     | 
| 
       262 
259 
     | 
    
         
             
                  def restore_env(env)
         
     | 
| 
       263 
     | 
    
         
            -
                    @src, @tree, @block_ial, @stack, 
     | 
| 
      
 260 
     | 
    
         
            +
                    @src, @tree, @block_ial, @stack, @text_type = *env
         
     | 
| 
       264 
261 
     | 
    
         
             
                  end
         
     | 
| 
       265 
262 
     | 
    
         | 
| 
       266 
263 
     | 
    
         
             
                  # Update the given attributes hash +attr+ with the information from the inline attribute list
         
     | 
| 
       267 
264 
     | 
    
         
             
                  # +ial+ and all referenced ALDs.
         
     | 
| 
       268 
265 
     | 
    
         
             
                  def update_attr_with_ial(attr, ial)
         
     | 
| 
       269 
     | 
    
         
            -
                    ial[:refs] 
     | 
| 
       270 
     | 
    
         
            -
                      update_attr_with_ial(attr, ref) if ref = @alds[ref]
         
     | 
| 
       271 
     | 
    
         
            -
                    end 
     | 
| 
       272 
     | 
    
         
            -
                    ial.each do |k,v|
         
     | 
| 
      
 266 
     | 
    
         
            +
                    ial[:refs]&.each do |ref|
         
     | 
| 
      
 267 
     | 
    
         
            +
                      update_attr_with_ial(attr, ref) if (ref = @alds[ref])
         
     | 
| 
      
 268 
     | 
    
         
            +
                    end
         
     | 
| 
      
 269 
     | 
    
         
            +
                    ial.each do |k, v|
         
     | 
| 
       273 
270 
     | 
    
         
             
                      if k == IAL_CLASS_ATTR
         
     | 
| 
       274 
     | 
    
         
            -
                        attr[k] =  
     | 
| 
       275 
     | 
    
         
            -
                        attr[k].lstrip!
         
     | 
| 
      
 271 
     | 
    
         
            +
                        attr[k] = "#{attr[k]} #{v}".lstrip
         
     | 
| 
       276 
272 
     | 
    
         
             
                      elsif k.kind_of?(String)
         
     | 
| 
       277 
273 
     | 
    
         
             
                        attr[k] = v
         
     | 
| 
       278 
274 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -281,13 +277,13 @@ module Kramdown 
     | 
|
| 
       281 
277 
     | 
    
         | 
| 
       282 
278 
     | 
    
         
             
                  # Update the raw text for automatic ID generation.
         
     | 
| 
       283 
279 
     | 
    
         
             
                  def update_raw_text(item)
         
     | 
| 
       284 
     | 
    
         
            -
                    raw_text = ''
         
     | 
| 
      
 280 
     | 
    
         
            +
                    raw_text = +''
         
     | 
| 
       285 
281 
     | 
    
         | 
| 
       286 
282 
     | 
    
         
             
                    append_text = lambda do |child|
         
     | 
| 
       287 
283 
     | 
    
         
             
                      if child.type == :text
         
     | 
| 
       288 
284 
     | 
    
         
             
                        raw_text << child.value
         
     | 
| 
       289 
285 
     | 
    
         
             
                      else
         
     | 
| 
       290 
     | 
    
         
            -
                        child.children.each {|c| append_text.call(c)}
         
     | 
| 
      
 286 
     | 
    
         
            +
                        child.children.each {|c| append_text.call(c) }
         
     | 
| 
       291 
287 
     | 
    
         
             
                      end
         
     | 
| 
       292 
288 
     | 
    
         
             
                    end
         
     | 
| 
       293 
289 
     | 
    
         | 
| 
         @@ -306,7 +302,7 @@ module Kramdown 
     | 
|
| 
       306 
302 
     | 
    
         
             
                    el
         
     | 
| 
       307 
303 
     | 
    
         
             
                  end
         
     | 
| 
       308 
304 
     | 
    
         | 
| 
       309 
     | 
    
         
            -
                   
     | 
| 
      
 305 
     | 
    
         
            +
                  @parsers = {}
         
     | 
| 
       310 
306 
     | 
    
         | 
| 
       311 
307 
     | 
    
         
             
                  # Struct class holding all the needed data for one block/span-level parser method.
         
     | 
| 
       312 
308 
     | 
    
         
             
                  Data = Struct.new(:name, :start_re, :span_start, :method)
         
     | 
| 
         @@ -321,18 +317,18 @@ module Kramdown 
     | 
|
| 
       321 
317 
     | 
    
         
             
                  # to the registry. The method name is automatically derived from the +name+ or can explicitly
         
     | 
| 
       322 
318 
     | 
    
         
             
                  # be set by using the +meth_name+ parameter.
         
     | 
| 
       323 
319 
     | 
    
         
             
                  def self.define_parser(name, start_re, span_start = nil, meth_name = "parse_#{name}")
         
     | 
| 
       324 
     | 
    
         
            -
                    raise "A parser with the name #{name} already exists!" if  
     | 
| 
       325 
     | 
    
         
            -
                     
     | 
| 
      
 320 
     | 
    
         
            +
                    raise "A parser with the name #{name} already exists!" if @parsers.key?(name)
         
     | 
| 
      
 321 
     | 
    
         
            +
                    @parsers[name] = Data.new(name, start_re, span_start, meth_name)
         
     | 
| 
       326 
322 
     | 
    
         
             
                  end
         
     | 
| 
       327 
323 
     | 
    
         | 
| 
       328 
324 
     | 
    
         
             
                  # Return the Data structure for the parser +name+.
         
     | 
| 
       329 
325 
     | 
    
         
             
                  def self.parser(name = nil)
         
     | 
| 
       330 
     | 
    
         
            -
                     
     | 
| 
      
 326 
     | 
    
         
            +
                    @parsers[name]
         
     | 
| 
       331 
327 
     | 
    
         
             
                  end
         
     | 
| 
       332 
328 
     | 
    
         | 
| 
       333 
329 
     | 
    
         
             
                  # Return +true+ if there is a parser called +name+.
         
     | 
| 
       334 
330 
     | 
    
         
             
                  def self.has_parser?(name)
         
     | 
| 
       335 
     | 
    
         
            -
                     
     | 
| 
      
 331 
     | 
    
         
            +
                    @parsers.key?(name)
         
     | 
| 
       336 
332 
     | 
    
         
             
                  end
         
     | 
| 
       337 
333 
     | 
    
         | 
| 
       338 
334 
     | 
    
         
             
                  # Regexp for matching indentation (one tab or four spaces)
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -19,7 +19,10 @@ module Kramdown 
     | 
|
| 
       19 
19 
     | 
    
         
             
                    @src.pos += @src.matched_size
         
     | 
| 
       20 
20 
     | 
    
         
             
                    abbrev_id, abbrev_text = @src[1], @src[2]
         
     | 
| 
       21 
21 
     | 
    
         
             
                    abbrev_text.strip!
         
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
      
 22 
     | 
    
         
            +
                    if @root.options[:abbrev_defs][abbrev_id]
         
     | 
| 
      
 23 
     | 
    
         
            +
                      warning("Duplicate abbreviation ID '#{abbrev_id}' on line #{start_line_number} " \
         
     | 
| 
      
 24 
     | 
    
         
            +
                              "- overwriting")
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
       23 
26 
     | 
    
         
             
                    @tree.children << new_block_el(:eob, :abbrev_def)
         
     | 
| 
       24 
27 
     | 
    
         
             
                    @root.options[:abbrev_defs][abbrev_id] = abbrev_text
         
     | 
| 
       25 
28 
     | 
    
         
             
                    @root.options[:abbrev_attr][abbrev_id] = @tree.children.last
         
     | 
| 
         @@ -37,9 +40,9 @@ module Kramdown 
     | 
|
| 
       37 
40 
     | 
    
         
             
                  # Replace the abbreviation text with elements.
         
     | 
| 
       38 
41 
     | 
    
         
             
                  def replace_abbreviations(el, regexps = nil)
         
     | 
| 
       39 
42 
     | 
    
         
             
                    return if @root.options[:abbrev_defs].empty?
         
     | 
| 
       40 
     | 
    
         
            -
                     
     | 
| 
       41 
     | 
    
         
            -
                      sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a,b| b.length <=> a.length}
         
     | 
| 
       42 
     | 
    
         
            -
                      regexps = [Regexp.union(*sorted_abbrevs.map {|k| /#{Regexp.escape(k)}/})]
         
     | 
| 
      
 43 
     | 
    
         
            +
                    unless regexps
         
     | 
| 
      
 44 
     | 
    
         
            +
                      sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a, b| b.length <=> a.length }
         
     | 
| 
      
 45 
     | 
    
         
            +
                      regexps = [Regexp.union(*sorted_abbrevs.map {|k| /#{Regexp.escape(k)}/ })]
         
     | 
| 
       43 
46 
     | 
    
         
             
                      regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries
         
     | 
| 
       44 
47 
     | 
    
         
             
                    end
         
     | 
| 
       45 
48 
     | 
    
         
             
                    el.children.map! do |child|
         
     | 
| 
         @@ -48,18 +51,18 @@ module Kramdown 
     | 
|
| 
       48 
51 
     | 
    
         
             
                          result = []
         
     | 
| 
       49 
52 
     | 
    
         
             
                          strscan = Kramdown::Utils::StringScanner.new(child.value, child.options[:location])
         
     | 
| 
       50 
53 
     | 
    
         
             
                          text_lineno = strscan.current_line_number
         
     | 
| 
       51 
     | 
    
         
            -
                          while temp = strscan.scan_until(regexps.last)
         
     | 
| 
      
 54 
     | 
    
         
            +
                          while (temp = strscan.scan_until(regexps.last))
         
     | 
| 
       52 
55 
     | 
    
         
             
                            abbr_lineno = strscan.current_line_number
         
     | 
| 
       53 
56 
     | 
    
         
             
                            abbr = strscan.scan(regexps.first) # begin of line case of abbr with \W char as first one
         
     | 
| 
       54 
57 
     | 
    
         
             
                            if abbr.nil?
         
     | 
| 
       55 
58 
     | 
    
         
             
                              temp << strscan.scan(/\W|^/)
         
     | 
| 
       56 
59 
     | 
    
         
             
                              abbr = strscan.scan(regexps.first)
         
     | 
| 
       57 
60 
     | 
    
         
             
                            end
         
     | 
| 
       58 
     | 
    
         
            -
                            result << Element.new(:text, temp, nil, : 
     | 
| 
       59 
     | 
    
         
            -
                            result << Element.new(:abbreviation, abbr, nil, : 
     | 
| 
      
 61 
     | 
    
         
            +
                            result << Element.new(:text, temp, nil, location: text_lineno)
         
     | 
| 
      
 62 
     | 
    
         
            +
                            result << Element.new(:abbreviation, abbr, nil, location: abbr_lineno)
         
     | 
| 
       60 
63 
     | 
    
         
             
                            text_lineno = strscan.current_line_number
         
     | 
| 
       61 
64 
     | 
    
         
             
                          end
         
     | 
| 
       62 
     | 
    
         
            -
                          result << Element.new(:text, strscan.rest, nil, : 
     | 
| 
      
 65 
     | 
    
         
            +
                          result << Element.new(:text, strscan.rest, nil, location: text_lineno)
         
     | 
| 
       63 
66 
     | 
    
         
             
                        else
         
     | 
| 
       64 
67 
     | 
    
         
             
                          child
         
     | 
| 
       65 
68 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -20,7 +20,7 @@ module Kramdown 
     | 
|
| 
       20 
20 
     | 
    
         
             
                    start_line_number = @src.current_line_number
         
     | 
| 
       21 
21 
     | 
    
         
             
                    @src.pos += @src.matched_size
         
     | 
| 
       22 
22 
     | 
    
         
             
                    href = (@src[2].nil? ? "mailto:#{@src[1]}" : @src[1])
         
     | 
| 
       23 
     | 
    
         
            -
                    el = Element.new(:a, nil, {'href' => href}, : 
     | 
| 
      
 23 
     | 
    
         
            +
                    el = Element.new(:a, nil, {'href' => href}, location: start_line_number)
         
     | 
| 
       24 
24 
     | 
    
         
             
                    add_text(@src[1].sub(/^mailto:/, ''), el)
         
     | 
| 
       25 
25 
     | 
    
         
             
                    @tree.children << el
         
     | 
| 
       26 
26 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -21,19 +21,18 @@ module Kramdown 
     | 
|
| 
       21 
21 
     | 
    
         
             
                  def parse_blockquote
         
     | 
| 
       22 
22 
     | 
    
         
             
                    start_line_number = @src.current_line_number
         
     | 
| 
       23 
23 
     | 
    
         
             
                    result = @src.scan(PARAGRAPH_MATCH)
         
     | 
| 
       24 
     | 
    
         
            -
                     
     | 
| 
      
 24 
     | 
    
         
            +
                    until @src.match?(self.class::LAZY_END)
         
     | 
| 
       25 
25 
     | 
    
         
             
                      result << @src.scan(PARAGRAPH_MATCH)
         
     | 
| 
       26 
26 
     | 
    
         
             
                    end
         
     | 
| 
       27 
27 
     | 
    
         
             
                    result.gsub!(BLOCKQUOTE_START, '')
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                    el = new_block_el(:blockquote, nil, nil, : 
     | 
| 
      
 29 
     | 
    
         
            +
                    el = new_block_el(:blockquote, nil, nil, location: start_line_number)
         
     | 
| 
       30 
30 
     | 
    
         
             
                    @tree.children << el
         
     | 
| 
       31 
31 
     | 
    
         
             
                    parse_blocks(el, result)
         
     | 
| 
       32 
32 
     | 
    
         
             
                    true
         
     | 
| 
       33 
33 
     | 
    
         
             
                  end
         
     | 
| 
       34 
34 
     | 
    
         
             
                  define_parser(:blockquote, BLOCKQUOTE_START)
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
36 
     | 
    
         
             
                end
         
     | 
| 
       38 
37 
     | 
    
         
             
              end
         
     | 
| 
       39 
38 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -25,12 +25,11 @@ module Kramdown 
     | 
|
| 
       25 
25 
     | 
    
         
             
                    data = @src.scan(self.class::CODEBLOCK_MATCH)
         
     | 
| 
       26 
26 
     | 
    
         
             
                    data.gsub!(/\n( {0,3}\S)/, ' \\1')
         
     | 
| 
       27 
27 
     | 
    
         
             
                    data.gsub!(INDENT, '')
         
     | 
| 
       28 
     | 
    
         
            -
                    @tree.children << new_block_el(:codeblock, data, nil, : 
     | 
| 
      
 28 
     | 
    
         
            +
                    @tree.children << new_block_el(:codeblock, data, nil, location: start_line_number)
         
     | 
| 
       29 
29 
     | 
    
         
             
                    true
         
     | 
| 
       30 
30 
     | 
    
         
             
                  end
         
     | 
| 
       31 
31 
     | 
    
         
             
                  define_parser(:codeblock, CODEBLOCK_START)
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
33 
     | 
    
         
             
                  FENCED_CODEBLOCK_START = /^~{3,}/
         
     | 
| 
       35 
34 
     | 
    
         
             
                  FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^\1\2*\s*?\n/m
         
     | 
| 
       36 
35 
     | 
    
         | 
| 
         @@ -39,7 +38,7 @@ module Kramdown 
     | 
|
| 
       39 
38 
     | 
    
         
             
                    if @src.check(self.class::FENCED_CODEBLOCK_MATCH)
         
     | 
| 
       40 
39 
     | 
    
         
             
                      start_line_number = @src.current_line_number
         
     | 
| 
       41 
40 
     | 
    
         
             
                      @src.pos += @src.matched_size
         
     | 
| 
       42 
     | 
    
         
            -
                      el = new_block_el(:codeblock, @src[5], nil, : 
     | 
| 
      
 41 
     | 
    
         
            +
                      el = new_block_el(:codeblock, @src[5], nil, location: start_line_number, fenced: true)
         
     | 
| 
       43 
42 
     | 
    
         
             
                      lang = @src[3].to_s.strip
         
     | 
| 
       44 
43 
     | 
    
         
             
                      unless lang.empty?
         
     | 
| 
       45 
44 
     | 
    
         
             
                        el.options[:lang] = lang
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -25,13 +25,13 @@ module Kramdown 
     | 
|
| 
       25 
25 
     | 
    
         
             
                      return
         
     | 
| 
       26 
26 
     | 
    
         
             
                    end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                    if text = @src.scan_until(/#{result}/)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    if (text = @src.scan_until(/#{result}/))
         
     | 
| 
       29 
29 
     | 
    
         
             
                      text.sub!(/#{result}\Z/, '')
         
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
      
 30 
     | 
    
         
            +
                      unless simple
         
     | 
| 
       31 
31 
     | 
    
         
             
                        text = text[1..-1] if text[0..0] == ' '
         
     | 
| 
       32 
32 
     | 
    
         
             
                        text = text[0..-2] if text[-1..-1] == ' '
         
     | 
| 
       33 
33 
     | 
    
         
             
                      end
         
     | 
| 
       34 
     | 
    
         
            -
                      @tree.children << Element.new(:codespan, text, nil, : 
     | 
| 
      
 34 
     | 
    
         
            +
                      @tree.children << Element.new(:codespan, text, nil, location: start_line_number)
         
     | 
| 
       35 
35 
     | 
    
         
             
                    else
         
     | 
| 
       36 
36 
     | 
    
         
             
                      @src.revert_pos(saved_pos)
         
     | 
| 
       37 
37 
     | 
    
         
             
                      add_text(result)
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -23,18 +23,18 @@ module Kramdown 
     | 
|
| 
       23 
23 
     | 
    
         
             
                    type = result[0..0]
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                    if (type == '_' && @src.pre_match =~ /[[:alpha:]-]\z/) || @src.check(/\s/) ||
         
     | 
| 
       26 
     | 
    
         
            -
                        @tree.type == element || @stack.any? {|el, _| el.type == element}
         
     | 
| 
      
 26 
     | 
    
         
            +
                        @tree.type == element || @stack.any? {|el, _| el.type == element }
         
     | 
| 
       27 
27 
     | 
    
         
             
                      add_text(result)
         
     | 
| 
       28 
28 
     | 
    
         
             
                      return
         
     | 
| 
       29 
29 
     | 
    
         
             
                    end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                    sub_parse = lambda do |delim, elem|
         
     | 
| 
       32 
     | 
    
         
            -
                      el = Element.new(elem, nil, nil, : 
     | 
| 
      
 32 
     | 
    
         
            +
                      el = Element.new(elem, nil, nil, location: start_line_number)
         
     | 
| 
       33 
33 
     | 
    
         
             
                      stop_re = /#{Regexp.escape(delim)}/
         
     | 
| 
       34 
34 
     | 
    
         
             
                      found = parse_spans(el, stop_re) do
         
     | 
| 
       35 
35 
     | 
    
         
             
                        (@src.pre_match[-1, 1] !~ /\s/) &&
         
     | 
| 
       36 
     | 
    
         
            -
                          (elem != :em || !@src.match?(/#{Regexp.escape(delim*2)}(?!#{Regexp.escape(delim)})/)) &&
         
     | 
| 
       37 
     | 
    
         
            -
                          (type != '_' || !@src.match?(/#{Regexp.escape(delim)}[[:alnum:]]/)) && el.children. 
     | 
| 
      
 36 
     | 
    
         
            +
                          (elem != :em || !@src.match?(/#{Regexp.escape(delim * 2)}(?!#{Regexp.escape(delim)})/)) &&
         
     | 
| 
      
 37 
     | 
    
         
            +
                          (type != '_' || !@src.match?(/#{Regexp.escape(delim)}[[:alnum:]]/)) && !el.children.empty?
         
     | 
| 
       38 
38 
     | 
    
         
             
                      end
         
     | 
| 
       39 
39 
     | 
    
         
             
                      [found, el, stop_re]
         
     | 
| 
       40 
40 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8; frozen_string_literal: true -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            #
         
     | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       7 
7 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -24,8 +24,7 @@ module Kramdown 
     | 
|
| 
       24 
24 
     | 
    
         
             
                      elsif id_and_or_class
         
     | 
| 
       25 
25 
     | 
    
         
             
                        id_and_or_class.scan(ALD_TYPE_ID_OR_CLASS).each do |id_attr, class_attr|
         
     | 
| 
       26 
26 
     | 
    
         
             
                          if class_attr
         
     | 
| 
       27 
     | 
    
         
            -
                            opts[IAL_CLASS_ATTR] =  
     | 
| 
       28 
     | 
    
         
            -
                            opts[IAL_CLASS_ATTR].lstrip!
         
     | 
| 
      
 27 
     | 
    
         
            +
                            opts[IAL_CLASS_ATTR] = "#{opts[IAL_CLASS_ATTR]} #{class_attr}".lstrip
         
     | 
| 
       29 
28 
     | 
    
         
             
                          else
         
     | 
| 
       30 
29 
     | 
    
         
             
                            opts['id'] = id_attr
         
     | 
| 
       31 
30 
     | 
    
         
             
                          end
         
     | 
| 
         @@ -35,16 +34,15 @@ module Kramdown 
     | 
|
| 
       35 
34 
     | 
    
         
             
                        opts[key] = val
         
     | 
| 
       36 
35 
     | 
    
         
             
                      end
         
     | 
| 
       37 
36 
     | 
    
         
             
                    end
         
     | 
| 
       38 
     | 
    
         
            -
                    warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs. 
     | 
| 
      
 37 
     | 
    
         
            +
                    warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs.empty?
         
     | 
| 
       39 
38 
     | 
    
         
             
                  end
         
     | 
| 
       40 
39 
     | 
    
         | 
| 
       41 
40 
     | 
    
         
             
                  # Update the +ial+ with the information from the inline attribute list +opts+.
         
     | 
| 
       42 
41 
     | 
    
         
             
                  def update_ial_with_ial(ial, opts)
         
     | 
| 
       43 
42 
     | 
    
         
             
                    (ial[:refs] ||= []) << opts[:refs]
         
     | 
| 
       44 
     | 
    
         
            -
                    opts.each do |k,v|
         
     | 
| 
      
 43 
     | 
    
         
            +
                    opts.each do |k, v|
         
     | 
| 
       45 
44 
     | 
    
         
             
                      if k == IAL_CLASS_ATTR
         
     | 
| 
       46 
     | 
    
         
            -
                        ial[k] =  
     | 
| 
       47 
     | 
    
         
            -
                        ial[k].lstrip!
         
     | 
| 
      
 45 
     | 
    
         
            +
                        ial[k] = "#{ial[k]} #{v}".lstrip
         
     | 
| 
       48 
46 
     | 
    
         
             
                      elsif k.kind_of?(String)
         
     | 
| 
       49 
47 
     | 
    
         
             
                        ial[k] = v
         
     | 
| 
       50 
48 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -67,7 +65,8 @@ module Kramdown 
     | 
|
| 
       67 
65 
     | 
    
         | 
| 
       68 
66 
     | 
    
         
             
                    if @src[4] || @src.matched == '{:/}'
         
     | 
| 
       69 
67 
     | 
    
         
             
                      name = (@src[4] ? "for '#{@src[4]}' " : '')
         
     | 
| 
       70 
     | 
    
         
            -
                      return error_block.call("Invalid extension stop tag #{name} found on line  
     | 
| 
      
 68 
     | 
    
         
            +
                      return error_block.call("Invalid extension stop tag #{name} found on line " \
         
     | 
| 
      
 69 
     | 
    
         
            +
                                              "#{start_line_number} - ignoring it")
         
     | 
| 
       71 
70 
     | 
    
         
             
                    end
         
     | 
| 
       72 
71 
     | 
    
         | 
| 
       73 
72 
     | 
    
         
             
                    ext = @src[1]
         
     | 
| 
         @@ -75,18 +74,20 @@ module Kramdown 
     | 
|
| 
       75 
74 
     | 
    
         
             
                    body = nil
         
     | 
| 
       76 
75 
     | 
    
         
             
                    parse_attribute_list(@src[2] || '', opts)
         
     | 
| 
       77 
76 
     | 
    
         | 
| 
       78 
     | 
    
         
            -
                     
     | 
| 
      
 77 
     | 
    
         
            +
                    unless @src[3]
         
     | 
| 
       79 
78 
     | 
    
         
             
                      stop_re = (type == :block ? /#{EXT_BLOCK_STOP_STR % ext}/ : /#{EXT_STOP_STR % ext}/)
         
     | 
| 
       80 
     | 
    
         
            -
                      if result = @src.scan_until(stop_re)
         
     | 
| 
      
 79 
     | 
    
         
            +
                      if (result = @src.scan_until(stop_re))
         
     | 
| 
       81 
80 
     | 
    
         
             
                        body = result.sub!(stop_re, '')
         
     | 
| 
       82 
81 
     | 
    
         
             
                        body.chomp! if type == :block
         
     | 
| 
       83 
82 
     | 
    
         
             
                      else
         
     | 
| 
       84 
     | 
    
         
            -
                        return error_block.call("No stop tag for extension '#{ext}' found on line  
     | 
| 
      
 83 
     | 
    
         
            +
                        return error_block.call("No stop tag for extension '#{ext}' found on line " \
         
     | 
| 
      
 84 
     | 
    
         
            +
                                                "#{start_line_number} - ignoring it")
         
     | 
| 
       85 
85 
     | 
    
         
             
                      end
         
     | 
| 
       86 
86 
     | 
    
         
             
                    end
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
       88 
88 
     | 
    
         
             
                    if !handle_extension(ext, opts, body, type, start_line_number)
         
     | 
| 
       89 
     | 
    
         
            -
                      error_block.call("Invalid extension with name '#{ext}' specified on line  
     | 
| 
      
 89 
     | 
    
         
            +
                      error_block.call("Invalid extension with name '#{ext}' specified on line " \
         
     | 
| 
      
 90 
     | 
    
         
            +
                                       "#{start_line_number} - ignoring it")
         
     | 
| 
       90 
91 
     | 
    
         
             
                    else
         
     | 
| 
       91 
92 
     | 
    
         
             
                      true
         
     | 
| 
       92 
93 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -95,26 +96,31 @@ module Kramdown 
     | 
|
| 
       95 
96 
     | 
    
         
             
                  def handle_extension(name, opts, body, type, line_no = nil)
         
     | 
| 
       96 
97 
     | 
    
         
             
                    case name
         
     | 
| 
       97 
98 
     | 
    
         
             
                    when 'comment'
         
     | 
| 
       98 
     | 
    
         
            -
                       
     | 
| 
      
 99 
     | 
    
         
            +
                      if body.kind_of?(String)
         
     | 
| 
      
 100 
     | 
    
         
            +
                        @tree.children << Element.new(:comment, body, nil, category: type, location: line_no)
         
     | 
| 
      
 101 
     | 
    
         
            +
                      end
         
     | 
| 
       99 
102 
     | 
    
         
             
                      true
         
     | 
| 
       100 
103 
     | 
    
         
             
                    when 'nomarkdown'
         
     | 
| 
       101 
     | 
    
         
            -
                       
     | 
| 
      
 104 
     | 
    
         
            +
                      if body.kind_of?(String)
         
     | 
| 
      
 105 
     | 
    
         
            +
                        @tree.children << Element.new(:raw, body, nil, category: type,
         
     | 
| 
      
 106 
     | 
    
         
            +
                                                      location: line_no, type: opts['type'].to_s.split(/\s+/))
         
     | 
| 
      
 107 
     | 
    
         
            +
                      end
         
     | 
| 
       102 
108 
     | 
    
         
             
                      true
         
     | 
| 
       103 
109 
     | 
    
         
             
                    when 'options'
         
     | 
| 
       104 
     | 
    
         
            -
                      opts.select do |k,v|
         
     | 
| 
      
 110 
     | 
    
         
            +
                      opts.select do |k, v|
         
     | 
| 
       105 
111 
     | 
    
         
             
                        k = k.to_sym
         
     | 
| 
       106 
112 
     | 
    
         
             
                        if Kramdown::Options.defined?(k)
         
     | 
| 
       107 
113 
     | 
    
         
             
                          begin
         
     | 
| 
       108 
114 
     | 
    
         
             
                            val = Kramdown::Options.parse(k, v)
         
     | 
| 
       109 
115 
     | 
    
         
             
                            @options[k] = val
         
     | 
| 
       110 
116 
     | 
    
         
             
                            (@root.options[:options] ||= {})[k] = val
         
     | 
| 
       111 
     | 
    
         
            -
                          rescue
         
     | 
| 
      
 117 
     | 
    
         
            +
                          rescue StandardError
         
     | 
| 
       112 
118 
     | 
    
         
             
                          end
         
     | 
| 
       113 
119 
     | 
    
         
             
                          false
         
     | 
| 
       114 
120 
     | 
    
         
             
                        else
         
     | 
| 
       115 
121 
     | 
    
         
             
                          true
         
     | 
| 
       116 
122 
     | 
    
         
             
                        end
         
     | 
| 
       117 
     | 
    
         
            -
                      end.each do |k, 
     | 
| 
      
 123 
     | 
    
         
            +
                      end.each do |k, _v|
         
     | 
| 
       118 
124 
     | 
    
         
             
                        warning("Unknown kramdown option '#{k}'")
         
     | 
| 
       119 
125 
     | 
    
         
             
                      end
         
     | 
| 
       120 
126 
     | 
    
         
             
                      @tree.children << new_block_el(:eob, :extension) if type == :block
         
     | 
| 
         @@ -124,7 +130,6 @@ module Kramdown 
     | 
|
| 
       124 
130 
     | 
    
         
             
                    end
         
     | 
| 
       125 
131 
     | 
    
         
             
                  end
         
     | 
| 
       126 
132 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
133 
     | 
    
         
             
                  ALD_ID_CHARS = /[\w-]/
         
     | 
| 
       129 
134 
     | 
    
         
             
                  ALD_ANY_CHARS = /\\\}|[^\}]/
         
     | 
| 
       130 
135 
     | 
    
         
             
                  ALD_ID_NAME = /\w#{ALD_ID_CHARS}*/
         
     | 
| 
         @@ -152,18 +157,19 @@ module Kramdown 
     | 
|
| 
       152 
157 
     | 
    
         
             
                  # location.
         
     | 
| 
       153 
158 
     | 
    
         
             
                  def parse_block_extensions
         
     | 
| 
       154 
159 
     | 
    
         
             
                    if @src.scan(ALD_START)
         
     | 
| 
       155 
     | 
    
         
            -
                      parse_attribute_list(@src[2], @alds[@src[1]] ||=  
     | 
| 
      
 160 
     | 
    
         
            +
                      parse_attribute_list(@src[2], @alds[@src[1]] ||= {})
         
     | 
| 
       156 
161 
     | 
    
         
             
                      @tree.children << new_block_el(:eob, :ald)
         
     | 
| 
       157 
162 
     | 
    
         
             
                      true
         
     | 
| 
       158 
163 
     | 
    
         
             
                    elsif @src.check(EXT_BLOCK_START)
         
     | 
| 
       159 
164 
     | 
    
         
             
                      parse_extension_start_tag(:block)
         
     | 
| 
       160 
165 
     | 
    
         
             
                    elsif @src.scan(IAL_BLOCK_START)
         
     | 
| 
       161 
166 
     | 
    
         
             
                      if @tree.children.last && @tree.children.last.type != :blank &&
         
     | 
| 
       162 
     | 
    
         
            -
                          (@tree.children.last.type != :eob || 
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
      
 167 
     | 
    
         
            +
                          (@tree.children.last.type != :eob ||
         
     | 
| 
      
 168 
     | 
    
         
            +
                           [:link_def, :abbrev_def, :footnote_def].include?(@tree.children.last.value))
         
     | 
| 
      
 169 
     | 
    
         
            +
                        parse_attribute_list(@src[1], @tree.children.last.options[:ial] ||= {})
         
     | 
| 
       164 
170 
     | 
    
         
             
                        @tree.children << new_block_el(:eob, :ial) unless @src.check(IAL_BLOCK_START)
         
     | 
| 
       165 
171 
     | 
    
         
             
                      else
         
     | 
| 
       166 
     | 
    
         
            -
                        parse_attribute_list(@src[1], @block_ial ||=  
     | 
| 
      
 172 
     | 
    
         
            +
                        parse_attribute_list(@src[1], @block_ial ||= {})
         
     | 
| 
       167 
173 
     | 
    
         
             
                      end
         
     | 
| 
       168 
174 
     | 
    
         
             
                      true
         
     | 
| 
       169 
175 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -172,7 +178,6 @@ module Kramdown 
     | 
|
| 
       172 
178 
     | 
    
         
             
                  end
         
     | 
| 
       173 
179 
     | 
    
         
             
                  define_parser(:block_extensions, BLOCK_EXTENSIONS_START)
         
     | 
| 
       174 
180 
     | 
    
         | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
181 
     | 
    
         
             
                  EXT_SPAN_START = /#{EXT_START_STR}|#{EXT_STOP_STR % ALD_ID_NAME}/
         
     | 
| 
       177 
182 
     | 
    
         
             
                  IAL_SPAN_START = /\{:(#{ALD_ANY_CHARS}+)\}/
         
     | 
| 
       178 
183 
     | 
    
         
             
                  SPAN_EXTENSIONS_START = /\{:/
         
     | 
| 
         @@ -184,9 +189,9 @@ module Kramdown 
     | 
|
| 
       184 
189 
     | 
    
         
             
                    elsif @src.check(IAL_SPAN_START)
         
     | 
| 
       185 
190 
     | 
    
         
             
                      if @tree.children.last && @tree.children.last.type != :text
         
     | 
| 
       186 
191 
     | 
    
         
             
                        @src.pos += @src.matched_size
         
     | 
| 
       187 
     | 
    
         
            -
                        attr =  
     | 
| 
      
 192 
     | 
    
         
            +
                        attr = {}
         
     | 
| 
       188 
193 
     | 
    
         
             
                        parse_attribute_list(@src[1], attr)
         
     | 
| 
       189 
     | 
    
         
            -
                        update_ial_with_ial(@tree.children.last.options[:ial] ||=  
     | 
| 
      
 194 
     | 
    
         
            +
                        update_ial_with_ial(@tree.children.last.options[:ial] ||= {}, attr)
         
     | 
| 
       190 
195 
     | 
    
         
             
                        update_attr_with_ial(@tree.children.last.attr, attr)
         
     | 
| 
       191 
196 
     | 
    
         
             
                      else
         
     | 
| 
       192 
197 
     | 
    
         
             
                        warning("Found span IAL after text - ignoring it")
         
     |