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
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a46f6cad363a7cede373f0a518b899c5f46fa0091be9475c8e679e9f5e211b9b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f8a7d90234109921697e0deb76b370c063759676c92a568e7f40e0a1274aa943
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2e4036db169432b82bc680f151a41e38b29354c07984cd165f056068d45b052e2a261d2c35786932d8c030a5a0277b1ddc8553e27ae75d585ba2d0074c61e15b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2ceebbad2256128c1c0a92f350c6bd275b6d6cbae1363ea6b00ed6779d80f029088dd28b447f95faa06c51a4eff6dbae49b7abe42e07e5d07f26f5465b911ebd
         
     | 
    
        data/CONTRIBUTERS
    CHANGED
    
    | 
         @@ -1,11 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
              Count Name
         
     | 
| 
       2 
2 
     | 
    
         
             
            ======= ====
         
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 3 
     | 
    
         
            +
                895 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       4 
4 
     | 
    
         
             
                  7 Christian Cornelssen <ccorn@1tein.de>
         
     | 
| 
       5 
5 
     | 
    
         
             
                  6 Gioele Barabucci <gioele@svario.it>
         
     | 
| 
       6 
6 
     | 
    
         
             
                  4 Ted Pak <powerpak006@gmail.com>
         
     | 
| 
       7 
7 
     | 
    
         
             
                  4 Shuanglei Tao <tsl0922@gmail.com>
         
     | 
| 
       8 
8 
     | 
    
         
             
                  4 Gleb Mazovetskiy <glex.spb@gmail.com>
         
     | 
| 
      
 9 
     | 
    
         
            +
                  4 Dan Allen <dan.j.allen@gmail.com>
         
     | 
| 
       9 
10 
     | 
    
         
             
                  4 Arne Brasseur <arne@arnebrasseur.net>
         
     | 
| 
       10 
11 
     | 
    
         
             
                  3 Henning Perl <perl@fast-sicher.de>
         
     | 
| 
       11 
12 
     | 
    
         
             
                  3 gettalong <t_leitner@gmx.at>
         
     | 
| 
         @@ -17,7 +18,6 @@ 
     | 
|
| 
       17 
18 
     | 
    
         
             
                  2 Nathanael Jones <nathanael.jones@gmail.com>
         
     | 
| 
       18 
19 
     | 
    
         
             
                  2 Max Meyer <dev@fedux.org>
         
     | 
| 
       19 
20 
     | 
    
         
             
                  2 Jo Hund <jhund@clearcove.ca>
         
     | 
| 
       20 
     | 
    
         
            -
                  2 Dan Allen <dan.j.allen@gmail.com>
         
     | 
| 
       21 
21 
     | 
    
         
             
                  2 Bran <m.versum@gmail.com>
         
     | 
| 
       22 
22 
     | 
    
         
             
                  1 winniehell <git@winniehell.de>
         
     | 
| 
       23 
23 
     | 
    
         
             
                  1 William <suttonwilliamd@gmail.com>
         
     | 
| 
         @@ -29,6 +29,7 @@ 
     | 
|
| 
       29 
29 
     | 
    
         
             
                  1 Tim Besard <tim.besard@gmail.com>
         
     | 
| 
       30 
30 
     | 
    
         
             
                  1 Tim Bates <tim@rumpuslabs.com>
         
     | 
| 
       31 
31 
     | 
    
         
             
                  1 Sun Yaozhu <yzyzsun@gmail.com>
         
     | 
| 
      
 32 
     | 
    
         
            +
                  1 Stephen Crosby <stevecrozz@gmail.com>
         
     | 
| 
       32 
33 
     | 
    
         
             
                  1 Simon Lydell <simon.lydell@gmail.com>
         
     | 
| 
       33 
34 
     | 
    
         
             
                  1 Shusaku NAKAZATO <cu393uc@gmail.com>
         
     | 
| 
       34 
35 
     | 
    
         
             
                  1 Sebastian Boehm <sebastian@sometimesfood.org>
         
     | 
| 
         @@ -45,6 +46,7 @@ 
     | 
|
| 
       45 
46 
     | 
    
         
             
                  1 Luca Barbato <luca.barbato@gmail.com>
         
     | 
| 
       46 
47 
     | 
    
         
             
                  1 l3kn <hello@l3kn.de>
         
     | 
| 
       47 
48 
     | 
    
         
             
                  1 Kir Kolyshkin <kolyshkin@gmail.com>
         
     | 
| 
      
 49 
     | 
    
         
            +
                  1 Jun Aruga <jaruga@redhat.com>
         
     | 
| 
       48 
50 
     | 
    
         
             
                  1 Jonathan Hooper <jonathan.hooper@gsa.gov>
         
     | 
| 
       49 
51 
     | 
    
         
             
                  1 John Croisant <jacius@gmail.com>
         
     | 
| 
       50 
52 
     | 
    
         
             
                  1 Joe Fiorini <joe@faithfulgeek.org>
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            2.0.0.beta1
         
     | 
    
        data/bin/kramdown
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # -*- coding: utf-8 -*-
         
     | 
| 
       3 
3 
     | 
    
         
             
            #
         
     | 
| 
       4 
4 
     | 
    
         
             
            #--
         
     | 
| 
       5 
     | 
    
         
            -
            # Copyright (C) 2009- 
     | 
| 
      
 5 
     | 
    
         
            +
            # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
         
     | 
| 
       6 
6 
     | 
    
         
             
            #
         
     | 
| 
       7 
7 
     | 
    
         
             
            # This file is part of kramdown which is licensed under the MIT.
         
     | 
| 
       8 
8 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -24,7 +24,7 @@ begin 
     | 
|
| 
       24 
24 
     | 
    
         
             
                             File.expand_path(ENV['XDG_CONFIG_HOME'] || '~/.config')
         
     | 
| 
       25 
25 
     | 
    
         
             
                           end
         
     | 
| 
       26 
26 
     | 
    
         
             
              config_file = File.join(config_dir, "kramdownrc")
         
     | 
| 
       27 
     | 
    
         
            -
            rescue
         
     | 
| 
      
 27 
     | 
    
         
            +
            rescue StandardError
         
     | 
| 
       28 
28 
     | 
    
         
             
            end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
            options = {}
         
     | 
| 
         @@ -32,23 +32,23 @@ format = ['html'] 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
            OptionParser.new do |opts|
         
     | 
| 
       34 
34 
     | 
    
         
             
              opts.banner = "Usage: kramdown [options] [FILE FILE ...]"
         
     | 
| 
       35 
     | 
    
         
            -
              opts.summary_indent = ' '*4
         
     | 
| 
      
 35 
     | 
    
         
            +
              opts.summary_indent = ' ' * 4
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
              opts.separator ""
         
     | 
| 
       38 
38 
     | 
    
         
             
              opts.separator "Command line options:"
         
     | 
| 
       39 
39 
     | 
    
         
             
              opts.separator ""
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
              opts.on("-i", "--input ARG", "Specify the input format: kramdown (default), " \
         
     | 
| 
       42 
     | 
    
         
            -
                      "html,  
     | 
| 
      
 42 
     | 
    
         
            +
                      "html, or markdown") {|v| options[:input] = v }
         
     | 
| 
       43 
43 
     | 
    
         
             
              opts.on("-o", "--output ARG", Array, "Specify one or more output formats separated by commas: " \
         
     | 
| 
       44 
     | 
    
         
            -
                      "html (default),", "kramdown, latex,  
     | 
| 
      
 44 
     | 
    
         
            +
                      "html (default),", "kramdown, latex, man or remove_html_tags") {|v| format = v }
         
     | 
| 
       45 
45 
     | 
    
         
             
              opts.separator ""
         
     | 
| 
       46 
46 
     | 
    
         
             
              opts.on("--no-config-file", "Do not read any configuration file. Default behavior is to check " \
         
     | 
| 
       47 
     | 
    
         
            -
                      "for a", "configuration file and read it if it exists.") {config_file = nil}
         
     | 
| 
      
 47 
     | 
    
         
            +
                      "for a", "configuration file and read it if it exists.") { config_file = nil }
         
     | 
| 
       48 
48 
     | 
    
         
             
              opts.on("--config-file FILE", "Specify the name of a configuration file with kramdown options " \
         
     | 
| 
       49 
49 
     | 
    
         
             
                      "in YAML", "format, e.g. \"auto_id_prefix: ARG\" instead of \"--auto-id-prefix ARG\"",
         
     | 
| 
       50 
50 
     | 
    
         
             
                      "and \"auto_ids: false\" instead of \"--no-auto-ids\".",
         
     | 
| 
       51 
     | 
    
         
            -
                      "Default: #{config_file}") {|v| config_file = v}
         
     | 
| 
      
 51 
     | 
    
         
            +
                      "Default: #{config_file}") {|v| config_file = v }
         
     | 
| 
       52 
52 
     | 
    
         
             
              opts.separator ""
         
     | 
| 
       53 
53 
     | 
    
         
             
              opts.on("-v", "--version", "Show the version of kramdown") do
         
     | 
| 
       54 
54 
     | 
    
         
             
                puts Kramdown::VERSION
         
     | 
| 
         @@ -66,26 +66,25 @@ OptionParser.new do |opts| 
     | 
|
| 
       66 
66 
     | 
    
         
             
              Kramdown::Options.definitions.sort.each do |n, definition|
         
     | 
| 
       67 
67 
     | 
    
         
             
                no = n.to_s.tr('_', '-')
         
     | 
| 
       68 
68 
     | 
    
         
             
                if definition.type == Kramdown::Options::Boolean
         
     | 
| 
       69 
     | 
    
         
            -
                  opts.on("--[no-]#{no}") {|v| options[n] = Kramdown::Options.parse(n, v)}
         
     | 
| 
      
 69 
     | 
    
         
            +
                  opts.on("--[no-]#{no}") {|v| options[n] = Kramdown::Options.parse(n, v) }
         
     | 
| 
       70 
70 
     | 
    
         
             
                else
         
     | 
| 
       71 
71 
     | 
    
         
             
                  type = definition.type
         
     | 
| 
       72 
72 
     | 
    
         
             
                  type = String if type == Symbol || type == Object
         
     | 
| 
       73 
     | 
    
         
            -
                  opts.on("--#{no} ARG", type) {|v| options[n] = Kramdown::Options.parse(n, v)}
         
     | 
| 
      
 73 
     | 
    
         
            +
                  opts.on("--#{no} ARG", type) {|v| options[n] = Kramdown::Options.parse(n, v) }
         
     | 
| 
       74 
74 
     | 
    
         
             
                end
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
76 
     | 
    
         
             
                definition.desc.split(/\n/).each do |line|
         
     | 
| 
       77 
     | 
    
         
            -
                  opts.separator opts.summary_indent + ' '*6 + line
         
     | 
| 
      
 77 
     | 
    
         
            +
                  opts.separator opts.summary_indent + ' ' * 6 + line
         
     | 
| 
       78 
78 
     | 
    
         
             
                end
         
     | 
| 
       79 
79 
     | 
    
         
             
                opts.separator ''
         
     | 
| 
       80 
80 
     | 
    
         
             
              end
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
81 
     | 
    
         
             
            end.parse!
         
     | 
| 
       83 
82 
     | 
    
         | 
| 
       84 
83 
     | 
    
         
             
            begin
         
     | 
| 
       85 
84 
     | 
    
         
             
              if config_file && File.exist?(config_file)
         
     | 
| 
       86 
85 
     | 
    
         
             
                config_file_options = YAML.safe_load(File.read(config_file), [Symbol])
         
     | 
| 
       87 
86 
     | 
    
         
             
                case config_file_options
         
     | 
| 
       88 
     | 
    
         
            -
                when nil 
     | 
| 
      
 87 
     | 
    
         
            +
                when nil # empty configuration file except perhaps YAML header and comments
         
     | 
| 
       89 
88 
     | 
    
         
             
                  # Nothing to do
         
     | 
| 
       90 
89 
     | 
    
         
             
                when Hash
         
     | 
| 
       91 
90 
     | 
    
         
             
                  options = config_file_options.merge(options)
         
     | 
| 
         @@ -95,9 +94,9 @@ begin 
     | 
|
| 
       95 
94 
     | 
    
         
             
              end
         
     | 
| 
       96 
95 
     | 
    
         
             
              doc = Kramdown::Document.new(ARGF.read, options)
         
     | 
| 
       97 
96 
     | 
    
         
             
              result = ''
         
     | 
| 
       98 
     | 
    
         
            -
              format.each {|f| result = doc.send("to_#{f}")}
         
     | 
| 
      
 97 
     | 
    
         
            +
              format.each {|f| result = doc.send("to_#{f}") }
         
     | 
| 
       99 
98 
     | 
    
         
             
              puts result
         
     | 
| 
       100 
     | 
    
         
            -
              doc.warnings.each {|warn| $stderr.puts "Warning: #{warn}"}
         
     | 
| 
      
 99 
     | 
    
         
            +
              doc.warnings.each {|warn| $stderr.puts "Warning: #{warn}" }
         
     | 
| 
       101 
100 
     | 
    
         
             
            rescue Kramdown::Error => e
         
     | 
| 
       102 
101 
     | 
    
         
             
              $stderr.puts "Error: #{e.message}"
         
     | 
| 
       103 
102 
     | 
    
         
             
              exit(1)
         
     | 
    
        data/lib/kramdown.rb
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
             
            #++
         
     | 
    
        data/lib/kramdown/converter.rb
    CHANGED
    
    | 
         @@ -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,7 +25,6 @@ module Kramdown 
     | 
|
| 
       25 
25 
     | 
    
         
             
                autoload :Kramdown, 'kramdown/converter/kramdown'
         
     | 
| 
       26 
26 
     | 
    
         
             
                autoload :Toc, 'kramdown/converter/toc'
         
     | 
| 
       27 
27 
     | 
    
         
             
                autoload :RemoveHtmlTags, 'kramdown/converter/remove_html_tags'
         
     | 
| 
       28 
     | 
    
         
            -
                autoload :Pdf, 'kramdown/converter/pdf'
         
     | 
| 
       29 
28 
     | 
    
         
             
                autoload :HashAST, 'kramdown/converter/hash_ast'
         
     | 
| 
       30 
29 
     | 
    
         
             
                autoload :HashAst, 'kramdown/converter/hash_ast'
         
     | 
| 
       31 
30 
     | 
    
         
             
                autoload :Man, 'kramdown/converter/man'
         
     | 
| 
         @@ -34,7 +33,7 @@ module Kramdown 
     | 
|
| 
       34 
33 
     | 
    
         | 
| 
       35 
34 
     | 
    
         
             
                configurable(:syntax_highlighter)
         
     | 
| 
       36 
35 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                ['Minted', " 
     | 
| 
      
 36 
     | 
    
         
            +
                ['Minted', "Rouge"].each do |klass_name|
         
     | 
| 
       38 
37 
     | 
    
         
             
                  kn_down = klass_name.downcase.intern
         
     | 
| 
       39 
38 
     | 
    
         
             
                  add_syntax_highlighter(kn_down) do |converter, text, lang, type, opts|
         
     | 
| 
       40 
39 
     | 
    
         
             
                    require "kramdown/converter/syntax_highlighter/#{kn_down}"
         
     | 
| 
         @@ -42,7 +41,7 @@ module Kramdown 
     | 
|
| 
       42 
41 
     | 
    
         
             
                    if !klass.const_defined?(:AVAILABLE) || klass::AVAILABLE
         
     | 
| 
       43 
42 
     | 
    
         
             
                      add_syntax_highlighter(kn_down, klass)
         
     | 
| 
       44 
43 
     | 
    
         
             
                    else
         
     | 
| 
       45 
     | 
    
         
            -
                      add_syntax_highlighter(kn_down) { 
     | 
| 
      
 44 
     | 
    
         
            +
                      add_syntax_highlighter(kn_down) { nil }
         
     | 
| 
       46 
45 
     | 
    
         
             
                    end
         
     | 
| 
       47 
46 
     | 
    
         
             
                    syntax_highlighter(kn_down).call(converter, text, lang, type, opts)
         
     | 
| 
       48 
47 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -50,7 +49,7 @@ module Kramdown 
     | 
|
| 
       50 
49 
     | 
    
         | 
| 
       51 
50 
     | 
    
         
             
                configurable(:math_engine)
         
     | 
| 
       52 
51 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                ["Mathjax" 
     | 
| 
      
 52 
     | 
    
         
            +
                ["Mathjax"].each do |klass_name|
         
     | 
| 
       54 
53 
     | 
    
         
             
                  kn_down = klass_name.downcase.intern
         
     | 
| 
       55 
54 
     | 
    
         
             
                  add_math_engine(kn_down) do |converter, el, opts|
         
     | 
| 
       56 
55 
     | 
    
         
             
                    require "kramdown/converter/math_engine/#{kn_down}"
         
     | 
| 
         @@ -58,7 +57,7 @@ module Kramdown 
     | 
|
| 
       58 
57 
     | 
    
         
             
                    if !klass.const_defined?(:AVAILABLE) || klass::AVAILABLE
         
     | 
| 
       59 
58 
     | 
    
         
             
                      add_math_engine(kn_down, klass)
         
     | 
| 
       60 
59 
     | 
    
         
             
                    else
         
     | 
| 
       61 
     | 
    
         
            -
                      add_math_engine(kn_down) { 
     | 
| 
      
 60 
     | 
    
         
            +
                      add_math_engine(kn_down) { nil }
         
     | 
| 
       62 
61 
     | 
    
         
             
                    end
         
     | 
| 
       63 
62 
     | 
    
         
             
                    math_engine(kn_down).call(converter, el, opts)
         
     | 
| 
       64 
63 
     | 
    
         
             
                  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 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -101,10 +101,16 @@ module Kramdown 
     | 
|
| 
       101 
101 
     | 
    
         
             
                  def self.convert(tree, options = {})
         
     | 
| 
       102 
102 
     | 
    
         
             
                    converter = new(tree, ::Kramdown::Options.merge(options.merge(tree.options[:options] || {})))
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                     
     | 
| 
      
 104 
     | 
    
         
            +
                    if !converter.options[:template].empty? && converter.apply_template_before?
         
     | 
| 
      
 105 
     | 
    
         
            +
                      apply_template(converter, '')
         
     | 
| 
      
 106 
     | 
    
         
            +
                    end
         
     | 
| 
       105 
107 
     | 
    
         
             
                    result = converter.convert(tree)
         
     | 
| 
       106 
     | 
    
         
            -
                     
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
                    if result.respond_to?(:encode!) && result.encoding != Encoding::BINARY
         
     | 
| 
      
 109 
     | 
    
         
            +
                      result.encode!(tree.options[:encoding])
         
     | 
| 
      
 110 
     | 
    
         
            +
                    end
         
     | 
| 
      
 111 
     | 
    
         
            +
                    if !converter.options[:template].empty? && converter.apply_template_after?
         
     | 
| 
      
 112 
     | 
    
         
            +
                      result = apply_template(converter, result)
         
     | 
| 
      
 113 
     | 
    
         
            +
                    end
         
     | 
| 
       108 
114 
     | 
    
         | 
| 
       109 
115 
     | 
    
         
             
                    [result, converter.warnings]
         
     | 
| 
       110 
116 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -112,7 +118,7 @@ module Kramdown 
     | 
|
| 
       112 
118 
     | 
    
         
             
                  # Convert the element +el+ and return the resulting object.
         
     | 
| 
       113 
119 
     | 
    
         
             
                  #
         
     | 
| 
       114 
120 
     | 
    
         
             
                  # This is the only method that has to be implemented by sub-classes!
         
     | 
| 
       115 
     | 
    
         
            -
                  def convert( 
     | 
| 
      
 121 
     | 
    
         
            +
                  def convert(_el)
         
     | 
| 
       116 
122 
     | 
    
         
             
                    raise NotImplementedError
         
     | 
| 
       117 
123 
     | 
    
         
             
                  end
         
     | 
| 
       118 
124 
     | 
    
         | 
| 
         @@ -125,28 +131,11 @@ module Kramdown 
     | 
|
| 
       125 
131 
     | 
    
         
             
                    obj = Object.new
         
     | 
| 
       126 
132 
     | 
    
         
             
                    obj.instance_variable_set(:@converter, converter)
         
     | 
| 
       127 
133 
     | 
    
         
             
                    obj.instance_variable_set(:@body, body)
         
     | 
| 
       128 
     | 
    
         
            -
                    erb.result(obj.instance_eval{binding})
         
     | 
| 
      
 134 
     | 
    
         
            +
                    erb.result(obj.instance_eval { binding })
         
     | 
| 
       129 
135 
     | 
    
         
             
                  end
         
     | 
| 
       130 
136 
     | 
    
         | 
| 
       131 
137 
     | 
    
         
             
                  # Return the template specified by +template+.
         
     | 
| 
       132 
     | 
    
         
            -
                  def self.get_template(template)
         
     | 
| 
       133 
     | 
    
         
            -
                    #DEPRECATED: use content of #get_template_new in 2.0
         
     | 
| 
       134 
     | 
    
         
            -
                    format_ext = '.' + self.name.split(/::/).last.downcase
         
     | 
| 
       135 
     | 
    
         
            -
                    shipped = File.join(::Kramdown.data_dir, template + format_ext)
         
     | 
| 
       136 
     | 
    
         
            -
                    if File.exist?(template)
         
     | 
| 
       137 
     | 
    
         
            -
                      File.read(template)
         
     | 
| 
       138 
     | 
    
         
            -
                    elsif File.exist?(template + format_ext)
         
     | 
| 
       139 
     | 
    
         
            -
                      File.read(template + format_ext)
         
     | 
| 
       140 
     | 
    
         
            -
                    elsif File.exist?(shipped)
         
     | 
| 
       141 
     | 
    
         
            -
                      File.read(shipped)
         
     | 
| 
       142 
     | 
    
         
            -
                    elsif template.start_with?('string://')
         
     | 
| 
       143 
     | 
    
         
            -
                      template.sub(/\Astring:\/\//, '')
         
     | 
| 
       144 
     | 
    
         
            -
                    else
         
     | 
| 
       145 
     | 
    
         
            -
                      get_template_new(template)
         
     | 
| 
       146 
     | 
    
         
            -
                    end
         
     | 
| 
       147 
     | 
    
         
            -
                  end
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
                  def self.get_template_new(template) # :nodoc:
         
     | 
| 
      
 138 
     | 
    
         
            +
                  def self.get_template(template) # :nodoc:
         
     | 
| 
       150 
139 
     | 
    
         
             
                    format_ext = '.' + ::Kramdown::Utils.snake_case(self.name.split(/::/).last)
         
     | 
| 
       151 
140 
     | 
    
         
             
                    shipped = File.join(::Kramdown.data_dir, template + format_ext)
         
     | 
| 
       152 
141 
     | 
    
         
             
                    if File.exist?(template)
         
     | 
| 
         @@ -232,10 +221,10 @@ module Kramdown 
     | 
|
| 
       232 
221 
     | 
    
         
             
                  def generate_id(str)
         
     | 
| 
       233 
222 
     | 
    
         
             
                    str = ::Kramdown::Utils::Unidecoder.decode(str) if @options[:transliterated_header_ids]
         
     | 
| 
       234 
223 
     | 
    
         
             
                    gen_id = basic_generate_id(str)
         
     | 
| 
       235 
     | 
    
         
            -
                    gen_id = 'section' if gen_id. 
     | 
| 
      
 224 
     | 
    
         
            +
                    gen_id = 'section' if gen_id.empty?
         
     | 
| 
       236 
225 
     | 
    
         
             
                    @used_ids ||= {}
         
     | 
| 
       237 
     | 
    
         
            -
                    if @used_ids. 
     | 
| 
       238 
     | 
    
         
            -
                      gen_id +=  
     | 
| 
      
 226 
     | 
    
         
            +
                    if @used_ids.key?(gen_id)
         
     | 
| 
      
 227 
     | 
    
         
            +
                      gen_id += "-#{@used_ids[gen_id] += 1}"
         
     | 
| 
       239 
228 
     | 
    
         
             
                    else
         
     | 
| 
       240 
229 
     | 
    
         
             
                      @used_ids[gen_id] = 0
         
     | 
| 
       241 
230 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -252,7 +241,7 @@ module Kramdown 
     | 
|
| 
       252 
241 
     | 
    
         
             
                    gen_id
         
     | 
| 
       253 
242 
     | 
    
         
             
                  end
         
     | 
| 
       254 
243 
     | 
    
         | 
| 
       255 
     | 
    
         
            -
                  SMART_QUOTE_INDICES = {: 
     | 
| 
      
 244 
     | 
    
         
            +
                  SMART_QUOTE_INDICES = {lsquo: 0, rsquo: 1, ldquo: 2, rdquo: 3} # :nodoc:
         
     | 
| 
       256 
245 
     | 
    
         | 
| 
       257 
246 
     | 
    
         
             
                  # Return the entity that represents the given smart_quote element.
         
     | 
| 
       258 
247 
     | 
    
         
             
                  def smart_quote_entity(el)
         
     | 
| 
         @@ -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,13 +19,13 @@ module Kramdown 
     | 
|
| 
       19 
19 
     | 
    
         
             
                class HashAST < Base
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                  def convert(el)
         
     | 
| 
       22 
     | 
    
         
            -
                    hash = {: 
     | 
| 
      
 22 
     | 
    
         
            +
                    hash = {type: el.type}
         
     | 
| 
       23 
23 
     | 
    
         
             
                    hash[:attr] = el.attr unless el.attr.empty?
         
     | 
| 
       24 
24 
     | 
    
         
             
                    hash[:value] = el.value unless el.value.nil?
         
     | 
| 
       25 
25 
     | 
    
         
             
                    hash[:options] = el.options unless el.options.empty?
         
     | 
| 
       26 
26 
     | 
    
         
             
                    unless el.children.empty?
         
     | 
| 
       27 
27 
     | 
    
         
             
                      hash[:children] = []
         
     | 
| 
       28 
     | 
    
         
            -
                      el.children.each {|child| hash[:children] << convert(child)}
         
     | 
| 
      
 28 
     | 
    
         
            +
                      el.children.each {|child| hash[:children] << convert(child) }
         
     | 
| 
       29 
29 
     | 
    
         
             
                    end
         
     | 
| 
       30 
30 
     | 
    
         
             
                    hash
         
     | 
| 
       31 
31 
     | 
    
         
             
                  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 
     | 
    
         
             
            #++
         
     | 
| 
         @@ -49,7 +49,7 @@ module Kramdown 
     | 
|
| 
       49 
49 
     | 
    
         
             
                  end
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
                  # The mapping of element type to conversion method.
         
     | 
| 
       52 
     | 
    
         
            -
                  DISPATCHER = Hash.new {|h,k| h[k] = "convert_#{k}"}
         
     | 
| 
      
 52 
     | 
    
         
            +
                  DISPATCHER = Hash.new {|h, k| h[k] = "convert_#{k}" }
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
                  # Dispatch the conversion of the element +el+ to a +convert_TYPE+ method using the +type+ of
         
     | 
| 
       55 
55 
     | 
    
         
             
                  # the element.
         
     | 
| 
         @@ -63,7 +63,7 @@ module Kramdown 
     | 
|
| 
       63 
63 
     | 
    
         
             
                  # Pushes +el+ onto the @stack before converting the child elements and pops it from the stack
         
     | 
| 
       64 
64 
     | 
    
         
             
                  # afterwards.
         
     | 
| 
       65 
65 
     | 
    
         
             
                  def inner(el, indent)
         
     | 
| 
       66 
     | 
    
         
            -
                    result = ''
         
     | 
| 
      
 66 
     | 
    
         
            +
                    result = +''
         
     | 
| 
       67 
67 
     | 
    
         
             
                    indent += @indent
         
     | 
| 
       68 
68 
     | 
    
         
             
                    @stack.push(el)
         
     | 
| 
       69 
69 
     | 
    
         
             
                    el.children.each do |inner_el|
         
     | 
| 
         @@ -73,11 +73,11 @@ module Kramdown 
     | 
|
| 
       73 
73 
     | 
    
         
             
                    result
         
     | 
| 
       74 
74 
     | 
    
         
             
                  end
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
                  def convert_blank( 
     | 
| 
      
 76 
     | 
    
         
            +
                  def convert_blank(_el, _indent)
         
     | 
| 
       77 
77 
     | 
    
         
             
                    "\n"
         
     | 
| 
       78 
78 
     | 
    
         
             
                  end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
     | 
    
         
            -
                  def convert_text(el,  
     | 
| 
      
 80 
     | 
    
         
            +
                  def convert_text(el, _indent)
         
     | 
| 
       81 
81 
     | 
    
         
             
                    escape_html(el.value, :text)
         
     | 
| 
       82 
82 
     | 
    
         
             
                  end
         
     | 
| 
       83 
83 
     | 
    
         | 
| 
         @@ -97,7 +97,7 @@ module Kramdown 
     | 
|
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
                    if highlighted_code
         
     | 
| 
       99 
99 
     | 
    
         
             
                      add_syntax_highlighter_to_class_attr(attr, lang || hl_opts[:default_lang])
         
     | 
| 
       100 
     | 
    
         
            -
                      "#{' '*indent}<div#{html_attributes(attr)}>#{highlighted_code}#{' '*indent}</div>\n"
         
     | 
| 
      
 100 
     | 
    
         
            +
                      "#{' ' * indent}<div#{html_attributes(attr)}>#{highlighted_code}#{' ' * indent}</div>\n"
         
     | 
| 
       101 
101 
     | 
    
         
             
                    else
         
     | 
| 
       102 
102 
     | 
    
         
             
                      result = escape_html(el.value)
         
     | 
| 
       103 
103 
     | 
    
         
             
                      result.chomp!
         
     | 
| 
         @@ -114,7 +114,8 @@ module Kramdown 
     | 
|
| 
       114 
114 
     | 
    
         
             
                      end
         
     | 
| 
       115 
115 
     | 
    
         
             
                      code_attr = {}
         
     | 
| 
       116 
116 
     | 
    
         
             
                      code_attr['class'] = "language-#{lang}" if lang
         
     | 
| 
       117 
     | 
    
         
            -
                      "#{' '*indent}<pre#{html_attributes(attr)} 
     | 
| 
      
 117 
     | 
    
         
            +
                      "#{' ' * indent}<pre#{html_attributes(attr)}>" \
         
     | 
| 
      
 118 
     | 
    
         
            +
                        "<code#{html_attributes(code_attr)}>#{result}\n</code></pre>\n"
         
     | 
| 
       118 
119 
     | 
    
         
             
                    end
         
     | 
| 
       119 
120 
     | 
    
         
             
                  end
         
     | 
| 
       120 
121 
     | 
    
         | 
| 
         @@ -133,42 +134,42 @@ module Kramdown 
     | 
|
| 
       133 
134 
     | 
    
         
             
                  end
         
     | 
| 
       134 
135 
     | 
    
         | 
| 
       135 
136 
     | 
    
         
             
                  def convert_hr(el, indent)
         
     | 
| 
       136 
     | 
    
         
            -
                    "#{' '*indent}<hr#{html_attributes(el.attr)} />\n"
         
     | 
| 
      
 137 
     | 
    
         
            +
                    "#{' ' * indent}<hr#{html_attributes(el.attr)} />\n"
         
     | 
| 
       137 
138 
     | 
    
         
             
                  end
         
     | 
| 
       138 
139 
     | 
    
         | 
| 
       139 
140 
     | 
    
         
             
                  def convert_ul(el, indent)
         
     | 
| 
       140 
141 
     | 
    
         
             
                    if !@toc_code && (el.options[:ial][:refs].include?('toc') rescue nil)
         
     | 
| 
       141 
     | 
    
         
            -
                      @toc_code = [el.type, el.attr, (0..128).to_a.map{ 
     | 
| 
      
 142 
     | 
    
         
            +
                      @toc_code = [el.type, el.attr, (0..128).to_a.map { rand(36).to_s(36) }.join]
         
     | 
| 
       142 
143 
     | 
    
         
             
                      @toc_code.last
         
     | 
| 
       143 
144 
     | 
    
         
             
                    elsif !@footnote_location && el.options[:ial] && (el.options[:ial][:refs] || []).include?('footnotes')
         
     | 
| 
       144 
     | 
    
         
            -
                      @footnote_location = (0..128).to_a.map{ 
     | 
| 
      
 145 
     | 
    
         
            +
                      @footnote_location = (0..128).to_a.map { rand(36).to_s(36) }.join
         
     | 
| 
       145 
146 
     | 
    
         
             
                    else
         
     | 
| 
       146 
147 
     | 
    
         
             
                      format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
         
     | 
| 
       147 
148 
     | 
    
         
             
                    end
         
     | 
| 
       148 
149 
     | 
    
         
             
                  end
         
     | 
| 
       149 
     | 
    
         
            -
                  alias  
     | 
| 
      
 150 
     | 
    
         
            +
                  alias convert_ol convert_ul
         
     | 
| 
       150 
151 
     | 
    
         | 
| 
       151 
152 
     | 
    
         
             
                  def convert_dl(el, indent)
         
     | 
| 
       152 
153 
     | 
    
         
             
                    format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
         
     | 
| 
       153 
154 
     | 
    
         
             
                  end
         
     | 
| 
       154 
155 
     | 
    
         | 
| 
       155 
156 
     | 
    
         
             
                  def convert_li(el, indent)
         
     | 
| 
       156 
     | 
    
         
            -
                    output = ' '*indent << "<#{el.type}" << html_attributes(el.attr) << ">"
         
     | 
| 
      
 157 
     | 
    
         
            +
                    output = ' ' * indent << "<#{el.type}" << html_attributes(el.attr) << ">"
         
     | 
| 
       157 
158 
     | 
    
         
             
                    res = inner(el, indent)
         
     | 
| 
       158 
159 
     | 
    
         
             
                    if el.children.empty? || (el.children.first.type == :p && el.children.first.options[:transparent])
         
     | 
| 
       159 
     | 
    
         
            -
                      output << res << (res =~ /\n\Z/ ? ' '*indent : '')
         
     | 
| 
      
 160 
     | 
    
         
            +
                      output << res << (res =~ /\n\Z/ ? ' ' * indent : '')
         
     | 
| 
       160 
161 
     | 
    
         
             
                    else
         
     | 
| 
       161 
     | 
    
         
            -
                      output << "\n" << res << ' '*indent
         
     | 
| 
      
 162 
     | 
    
         
            +
                      output << "\n" << res << ' ' * indent
         
     | 
| 
       162 
163 
     | 
    
         
             
                    end
         
     | 
| 
       163 
164 
     | 
    
         
             
                    output << "</#{el.type}>\n"
         
     | 
| 
       164 
165 
     | 
    
         
             
                  end
         
     | 
| 
       165 
     | 
    
         
            -
                  alias  
     | 
| 
      
 166 
     | 
    
         
            +
                  alias convert_dd convert_li
         
     | 
| 
       166 
167 
     | 
    
         | 
| 
       167 
168 
     | 
    
         
             
                  def convert_dt(el, indent)
         
     | 
| 
       168 
169 
     | 
    
         
             
                    attr = el.attr.dup
         
     | 
| 
       169 
170 
     | 
    
         
             
                    @stack.last.options[:ial][:refs].each do |ref|
         
     | 
| 
       170 
171 
     | 
    
         
             
                      if ref =~ /\Aauto_ids(?:-([\w-]+))?/
         
     | 
| 
       171 
     | 
    
         
            -
                        attr['id'] =  
     | 
| 
      
 172 
     | 
    
         
            +
                        attr['id'] = "#{$1}#{basic_generate_id(el.options[:raw_text])}".lstrip
         
     | 
| 
       172 
173 
     | 
    
         
             
                        break
         
     | 
| 
       173 
174 
     | 
    
         
             
                      end
         
     | 
| 
       174 
175 
     | 
    
         
             
                    end if !attr['id'] && @stack.last.options[:ial] && @stack.last.options[:ial][:refs]
         
     | 
| 
         @@ -178,17 +179,20 @@ module Kramdown 
     | 
|
| 
       178 
179 
     | 
    
         
             
                  def convert_html_element(el, indent)
         
     | 
| 
       179 
180 
     | 
    
         
             
                    res = inner(el, indent)
         
     | 
| 
       180 
181 
     | 
    
         
             
                    if el.options[:category] == :span
         
     | 
| 
       181 
     | 
    
         
            -
                      "<#{el.value}#{html_attributes(el.attr)}"  
     | 
| 
      
 182 
     | 
    
         
            +
                      "<#{el.value}#{html_attributes(el.attr)}" + \
         
     | 
| 
      
 183 
     | 
    
         
            +
                        (res.empty? && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value) ? " />" : ">#{res}</#{el.value}>")
         
     | 
| 
       182 
184 
     | 
    
         
             
                    else
         
     | 
| 
       183 
     | 
    
         
            -
                      output = ''
         
     | 
| 
       184 
     | 
    
         
            -
                       
     | 
| 
      
 185 
     | 
    
         
            +
                      output = +''
         
     | 
| 
      
 186 
     | 
    
         
            +
                      if @stack.last.type != :html_element || @stack.last.options[:content_model] != :raw
         
     | 
| 
      
 187 
     | 
    
         
            +
                        output << ' ' * indent
         
     | 
| 
      
 188 
     | 
    
         
            +
                      end
         
     | 
| 
       185 
189 
     | 
    
         
             
                      output << "<#{el.value}#{html_attributes(el.attr)}"
         
     | 
| 
       186 
190 
     | 
    
         
             
                      if el.options[:is_closed] && el.options[:content_model] == :raw
         
     | 
| 
       187 
191 
     | 
    
         
             
                        output << " />"
         
     | 
| 
       188 
192 
     | 
    
         
             
                      elsif !res.empty? && el.options[:content_model] != :block
         
     | 
| 
       189 
193 
     | 
    
         
             
                        output << ">#{res}</#{el.value}>"
         
     | 
| 
       190 
194 
     | 
    
         
             
                      elsif !res.empty?
         
     | 
| 
       191 
     | 
    
         
            -
                        output << ">\n#{res.chomp}\n" 
     | 
| 
      
 195 
     | 
    
         
            +
                        output << ">\n#{res.chomp}\n" << ' ' * indent << "</#{el.value}>"
         
     | 
| 
       192 
196 
     | 
    
         
             
                      elsif HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
         
     | 
| 
       193 
197 
     | 
    
         
             
                        output << " />"
         
     | 
| 
       194 
198 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -200,21 +204,22 @@ module Kramdown 
     | 
|
| 
       200 
204 
     | 
    
         
             
                  end
         
     | 
| 
       201 
205 
     | 
    
         | 
| 
       202 
206 
     | 
    
         
             
                  def convert_xml_comment(el, indent)
         
     | 
| 
       203 
     | 
    
         
            -
                    if el.options[:category] == :block && 
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
      
 207 
     | 
    
         
            +
                    if el.options[:category] == :block &&
         
     | 
| 
      
 208 
     | 
    
         
            +
                        (@stack.last.type != :html_element || @stack.last.options[:content_model] != :raw)
         
     | 
| 
      
 209 
     | 
    
         
            +
                      ' ' * indent << el.value << "\n"
         
     | 
| 
       205 
210 
     | 
    
         
             
                    else
         
     | 
| 
       206 
211 
     | 
    
         
             
                      el.value
         
     | 
| 
       207 
212 
     | 
    
         
             
                    end
         
     | 
| 
       208 
213 
     | 
    
         
             
                  end
         
     | 
| 
       209 
     | 
    
         
            -
                  alias  
     | 
| 
      
 214 
     | 
    
         
            +
                  alias convert_xml_pi convert_xml_comment
         
     | 
| 
       210 
215 
     | 
    
         | 
| 
       211 
216 
     | 
    
         
             
                  def convert_table(el, indent)
         
     | 
| 
       212 
217 
     | 
    
         
             
                    format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
         
     | 
| 
       213 
218 
     | 
    
         
             
                  end
         
     | 
| 
       214 
     | 
    
         
            -
                  alias  
     | 
| 
       215 
     | 
    
         
            -
                  alias  
     | 
| 
       216 
     | 
    
         
            -
                  alias  
     | 
| 
       217 
     | 
    
         
            -
                  alias  
     | 
| 
      
 219 
     | 
    
         
            +
                  alias convert_thead convert_table
         
     | 
| 
      
 220 
     | 
    
         
            +
                  alias convert_tbody convert_table
         
     | 
| 
      
 221 
     | 
    
         
            +
                  alias convert_tfoot convert_table
         
     | 
| 
      
 222 
     | 
    
         
            +
                  alias convert_tr convert_table
         
     | 
| 
       218 
223 
     | 
    
         | 
| 
       219 
224 
     | 
    
         
             
                  ENTITY_NBSP = ::Kramdown::Utils::Entities.entity('nbsp') # :nodoc:
         
     | 
| 
       220 
225 
     | 
    
         | 
| 
         @@ -225,20 +230,20 @@ module Kramdown 
     | 
|
| 
       225 
230 
     | 
    
         
             
                    alignment = @stack[-3].options[:alignment][@stack.last.children.index(el)]
         
     | 
| 
       226 
231 
     | 
    
         
             
                    if alignment != :default
         
     | 
| 
       227 
232 
     | 
    
         
             
                      attr = el.attr.dup
         
     | 
| 
       228 
     | 
    
         
            -
                      attr['style'] = (attr. 
     | 
| 
      
 233 
     | 
    
         
            +
                      attr['style'] = (attr.key?('style') ? "#{attr['style']}; " : '') + "text-align: #{alignment}"
         
     | 
| 
       229 
234 
     | 
    
         
             
                    end
         
     | 
| 
       230 
235 
     | 
    
         
             
                    format_as_block_html(type, attr, res.empty? ? entity_to_str(ENTITY_NBSP) : res, indent)
         
     | 
| 
       231 
236 
     | 
    
         
             
                  end
         
     | 
| 
       232 
237 
     | 
    
         | 
| 
       233 
238 
     | 
    
         
             
                  def convert_comment(el, indent)
         
     | 
| 
       234 
239 
     | 
    
         
             
                    if el.options[:category] == :block
         
     | 
| 
       235 
     | 
    
         
            -
                      "#{' '*indent}<!-- #{el.value} -->\n"
         
     | 
| 
      
 240 
     | 
    
         
            +
                      "#{' ' * indent}<!-- #{el.value} -->\n"
         
     | 
| 
       236 
241 
     | 
    
         
             
                    else
         
     | 
| 
       237 
242 
     | 
    
         
             
                      "<!-- #{el.value} -->"
         
     | 
| 
       238 
243 
     | 
    
         
             
                    end
         
     | 
| 
       239 
244 
     | 
    
         
             
                  end
         
     | 
| 
       240 
245 
     | 
    
         | 
| 
       241 
     | 
    
         
            -
                  def convert_br( 
     | 
| 
      
 246 
     | 
    
         
            +
                  def convert_br(_el, _indent)
         
     | 
| 
       242 
247 
     | 
    
         
             
                    "<br />"
         
     | 
| 
       243 
248 
     | 
    
         
             
                  end
         
     | 
| 
       244 
249 
     | 
    
         | 
| 
         @@ -246,11 +251,11 @@ module Kramdown 
     | 
|
| 
       246 
251 
     | 
    
         
             
                    format_as_span_html(el.type, el.attr, inner(el, indent))
         
     | 
| 
       247 
252 
     | 
    
         
             
                  end
         
     | 
| 
       248 
253 
     | 
    
         | 
| 
       249 
     | 
    
         
            -
                  def convert_img(el,  
     | 
| 
      
 254 
     | 
    
         
            +
                  def convert_img(el, _indent)
         
     | 
| 
       250 
255 
     | 
    
         
             
                    "<img#{html_attributes(el.attr)} />"
         
     | 
| 
       251 
256 
     | 
    
         
             
                  end
         
     | 
| 
       252 
257 
     | 
    
         | 
| 
       253 
     | 
    
         
            -
                  def convert_codespan(el,  
     | 
| 
      
 258 
     | 
    
         
            +
                  def convert_codespan(el, _indent)
         
     | 
| 
       254 
259 
     | 
    
         
             
                    attr = el.attr.dup
         
     | 
| 
       255 
260 
     | 
    
         
             
                    lang = extract_code_language(attr)
         
     | 
| 
       256 
261 
     | 
    
         
             
                    hl_opts = {}
         
     | 
| 
         @@ -264,7 +269,7 @@ module Kramdown 
     | 
|
| 
       264 
269 
     | 
    
         
             
                    format_as_span_html('code', attr, result)
         
     | 
| 
       265 
270 
     | 
    
         
             
                  end
         
     | 
| 
       266 
271 
     | 
    
         | 
| 
       267 
     | 
    
         
            -
                  def convert_footnote(el,  
     | 
| 
      
 272 
     | 
    
         
            +
                  def convert_footnote(el, _indent)
         
     | 
| 
       268 
273 
     | 
    
         
             
                    repeat = ''
         
     | 
| 
       269 
274 
     | 
    
         
             
                    if (footnote = @footnotes_by_name[el.options[:name]])
         
     | 
| 
       270 
275 
     | 
    
         
             
                      number = footnote[2]
         
     | 
| 
         @@ -275,10 +280,11 @@ module Kramdown 
     | 
|
| 
       275 
280 
     | 
    
         
             
                      @footnotes << [el.options[:name], el.value, number, 0]
         
     | 
| 
       276 
281 
     | 
    
         
             
                      @footnotes_by_name[el.options[:name]] = @footnotes.last
         
     | 
| 
       277 
282 
     | 
    
         
             
                    end
         
     | 
| 
       278 
     | 
    
         
            -
                    "<sup id=\"fnref:#{el.options[:name]}#{repeat}\" 
     | 
| 
      
 283 
     | 
    
         
            +
                    "<sup id=\"fnref:#{el.options[:name]}#{repeat}\">" \
         
     | 
| 
      
 284 
     | 
    
         
            +
                      "<a href=\"#fn:#{el.options[:name]}\" class=\"footnote\">#{number}</a></sup>"
         
     | 
| 
       279 
285 
     | 
    
         
             
                  end
         
     | 
| 
       280 
286 
     | 
    
         | 
| 
       281 
     | 
    
         
            -
                  def convert_raw(el,  
     | 
| 
      
 287 
     | 
    
         
            +
                  def convert_raw(el, _indent)
         
     | 
| 
       282 
288 
     | 
    
         
             
                    if !el.options[:type] || el.options[:type].empty? || el.options[:type].include?('html')
         
     | 
| 
       283 
289 
     | 
    
         
             
                      el.value + (el.options[:category] == :block ? "\n" : '')
         
     | 
| 
       284 
290 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -289,39 +295,41 @@ module Kramdown 
     | 
|
| 
       289 
295 
     | 
    
         
             
                  def convert_em(el, indent)
         
     | 
| 
       290 
296 
     | 
    
         
             
                    format_as_span_html(el.type, el.attr, inner(el, indent))
         
     | 
| 
       291 
297 
     | 
    
         
             
                  end
         
     | 
| 
       292 
     | 
    
         
            -
                  alias  
     | 
| 
      
 298 
     | 
    
         
            +
                  alias convert_strong convert_em
         
     | 
| 
       293 
299 
     | 
    
         | 
| 
       294 
     | 
    
         
            -
                  def convert_entity(el,  
     | 
| 
      
 300 
     | 
    
         
            +
                  def convert_entity(el, _indent)
         
     | 
| 
       295 
301 
     | 
    
         
             
                    entity_to_str(el.value, el.options[:original])
         
     | 
| 
       296 
302 
     | 
    
         
             
                  end
         
     | 
| 
       297 
303 
     | 
    
         | 
| 
       298 
304 
     | 
    
         
             
                  TYPOGRAPHIC_SYMS = {
         
     | 
| 
       299 
     | 
    
         
            -
                    : 
     | 
| 
       300 
     | 
    
         
            -
                    : 
     | 
| 
       301 
     | 
    
         
            -
                    : 
     | 
| 
       302 
     | 
    
         
            -
                    : 
     | 
| 
       303 
     | 
    
         
            -
             
     | 
| 
       304 
     | 
    
         
            -
                    : 
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
      
 305 
     | 
    
         
            +
                    mdash: [::Kramdown::Utils::Entities.entity('mdash')],
         
     | 
| 
      
 306 
     | 
    
         
            +
                    ndash: [::Kramdown::Utils::Entities.entity('ndash')],
         
     | 
| 
      
 307 
     | 
    
         
            +
                    hellip: [::Kramdown::Utils::Entities.entity('hellip')],
         
     | 
| 
      
 308 
     | 
    
         
            +
                    laquo_space: [::Kramdown::Utils::Entities.entity('laquo'),
         
     | 
| 
      
 309 
     | 
    
         
            +
                                  ::Kramdown::Utils::Entities.entity('nbsp')],
         
     | 
| 
      
 310 
     | 
    
         
            +
                    raquo_space: [::Kramdown::Utils::Entities.entity('nbsp'),
         
     | 
| 
      
 311 
     | 
    
         
            +
                                  ::Kramdown::Utils::Entities.entity('raquo')],
         
     | 
| 
      
 312 
     | 
    
         
            +
                    laquo: [::Kramdown::Utils::Entities.entity('laquo')],
         
     | 
| 
      
 313 
     | 
    
         
            +
                    raquo: [::Kramdown::Utils::Entities.entity('raquo')],
         
     | 
| 
       306 
314 
     | 
    
         
             
                  } # :nodoc:
         
     | 
| 
       307 
     | 
    
         
            -
                  def convert_typographic_sym(el,  
     | 
| 
      
 315 
     | 
    
         
            +
                  def convert_typographic_sym(el, _indent)
         
     | 
| 
       308 
316 
     | 
    
         
             
                    if (result = @options[:typographic_symbols][el.value])
         
     | 
| 
       309 
317 
     | 
    
         
             
                      escape_html(result, :text)
         
     | 
| 
       310 
318 
     | 
    
         
             
                    else
         
     | 
| 
       311 
     | 
    
         
            -
                      TYPOGRAPHIC_SYMS[el.value].map {|e| entity_to_str(e)}.join('')
         
     | 
| 
      
 319 
     | 
    
         
            +
                      TYPOGRAPHIC_SYMS[el.value].map {|e| entity_to_str(e) }.join('')
         
     | 
| 
       312 
320 
     | 
    
         
             
                    end
         
     | 
| 
       313 
321 
     | 
    
         
             
                  end
         
     | 
| 
       314 
322 
     | 
    
         | 
| 
       315 
     | 
    
         
            -
                  def convert_smart_quote(el,  
     | 
| 
      
 323 
     | 
    
         
            +
                  def convert_smart_quote(el, _indent)
         
     | 
| 
       316 
324 
     | 
    
         
             
                    entity_to_str(smart_quote_entity(el))
         
     | 
| 
       317 
325 
     | 
    
         
             
                  end
         
     | 
| 
       318 
326 
     | 
    
         | 
| 
       319 
327 
     | 
    
         
             
                  def convert_math(el, indent)
         
     | 
| 
       320 
     | 
    
         
            -
                    if (result = format_math(el, : 
     | 
| 
      
 328 
     | 
    
         
            +
                    if (result = format_math(el, indent: indent))
         
     | 
| 
       321 
329 
     | 
    
         
             
                      result
         
     | 
| 
       322 
330 
     | 
    
         
             
                    else
         
     | 
| 
       323 
331 
     | 
    
         
             
                      attr = el.attr.dup
         
     | 
| 
       324 
     | 
    
         
            -
                       
     | 
| 
      
 332 
     | 
    
         
            +
                      attr['class'] = "#{attr['class']} kdmath".lstrip
         
     | 
| 
       325 
333 
     | 
    
         
             
                      if el.options[:category] == :block
         
     | 
| 
       326 
334 
     | 
    
         
             
                        format_as_block_html('div', attr, "$$\n#{el.value}\n$$", indent)
         
     | 
| 
       327 
335 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -330,7 +338,7 @@ module Kramdown 
     | 
|
| 
       330 
338 
     | 
    
         
             
                    end
         
     | 
| 
       331 
339 
     | 
    
         
             
                  end
         
     | 
| 
       332 
340 
     | 
    
         | 
| 
       333 
     | 
    
         
            -
                  def convert_abbreviation(el,  
     | 
| 
      
 341 
     | 
    
         
            +
                  def convert_abbreviation(el, _indent)
         
     | 
| 
       334 
342 
     | 
    
         
             
                    title = @root.options[:abbrev_defs][el.value]
         
     | 
| 
       335 
343 
     | 
    
         
             
                    attr = @root.options[:abbrev_attr][el.value].dup
         
     | 
| 
       336 
344 
     | 
    
         
             
                    attr['title'] = title unless title.empty?
         
     | 
| 
         @@ -346,7 +354,7 @@ module Kramdown 
     | 
|
| 
       346 
354 
     | 
    
         
             
                    end
         
     | 
| 
       347 
355 
     | 
    
         
             
                    if @toc_code
         
     | 
| 
       348 
356 
     | 
    
         
             
                      toc_tree = generate_toc_tree(@toc, @toc_code[0], @toc_code[1] || {})
         
     | 
| 
       349 
     | 
    
         
            -
                      text = if toc_tree.children. 
     | 
| 
      
 357 
     | 
    
         
            +
                      text = if !toc_tree.children.empty?
         
     | 
| 
       350 
358 
     | 
    
         
             
                               convert(toc_tree, 0)
         
     | 
| 
       351 
359 
     | 
    
         
             
                             else
         
     | 
| 
       352 
360 
     | 
    
         
             
                               ''
         
     | 
| 
         @@ -363,13 +371,13 @@ module Kramdown 
     | 
|
| 
       363 
371 
     | 
    
         | 
| 
       364 
372 
     | 
    
         
             
                  # Format the given element as block HTML.
         
     | 
| 
       365 
373 
     | 
    
         
             
                  def format_as_block_html(name, attr, body, indent)
         
     | 
| 
       366 
     | 
    
         
            -
                    "#{' '*indent}<#{name}#{html_attributes(attr)}>#{body}</#{name}>\n"
         
     | 
| 
      
 374 
     | 
    
         
            +
                    "#{' ' * indent}<#{name}#{html_attributes(attr)}>#{body}</#{name}>\n"
         
     | 
| 
       367 
375 
     | 
    
         
             
                  end
         
     | 
| 
       368 
376 
     | 
    
         | 
| 
       369 
377 
     | 
    
         
             
                  # Format the given element as block HTML with a newline after the start tag and indentation
         
     | 
| 
       370 
378 
     | 
    
         
             
                  # before the end tag.
         
     | 
| 
       371 
379 
     | 
    
         
             
                  def format_as_indented_block_html(name, attr, body, indent)
         
     | 
| 
       372 
     | 
    
         
            -
                    "#{' '*indent}<#{name}#{html_attributes(attr)}>\n#{body}#{' '*indent}</#{name}>\n"
         
     | 
| 
      
 380 
     | 
    
         
            +
                    "#{' ' * indent}<#{name}#{html_attributes(attr)}>\n#{body}#{' ' * indent}</#{name}>\n"
         
     | 
| 
       373 
381 
     | 
    
         
             
                  end
         
     | 
| 
       374 
382 
     | 
    
         | 
| 
       375 
383 
     | 
    
         
             
                  # Add the syntax highlighter name to the 'class' attribute of the given attribute hash. And
         
     | 
| 
         @@ -381,12 +389,12 @@ module Kramdown 
     | 
|
| 
       381 
389 
     | 
    
         | 
| 
       382 
390 
     | 
    
         
             
                  # Generate and return an element tree for the table of contents.
         
     | 
| 
       383 
391 
     | 
    
         
             
                  def generate_toc_tree(toc, type, attr)
         
     | 
| 
       384 
     | 
    
         
            -
                    sections = Element.new(type, nil, attr)
         
     | 
| 
      
 392 
     | 
    
         
            +
                    sections = Element.new(type, nil, attr.dup)
         
     | 
| 
       385 
393 
     | 
    
         
             
                    sections.attr['id'] ||= 'markdown-toc'
         
     | 
| 
       386 
394 
     | 
    
         
             
                    stack = []
         
     | 
| 
       387 
395 
     | 
    
         
             
                    toc.each do |level, id, children|
         
     | 
| 
       388 
     | 
    
         
            -
                      li = Element.new(:li, nil, nil,  
     | 
| 
       389 
     | 
    
         
            -
                      li.children << Element.new(:p, nil, nil,  
     | 
| 
      
 396 
     | 
    
         
            +
                      li = Element.new(:li, nil, nil, level: level)
         
     | 
| 
      
 397 
     | 
    
         
            +
                      li.children << Element.new(:p, nil, nil, transparent: true)
         
     | 
| 
       390 
398 
     | 
    
         
             
                      a = Element.new(:a, nil)
         
     | 
| 
       391 
399 
     | 
    
         
             
                      a.attr['href'] = "##{id}"
         
     | 
| 
       392 
400 
     | 
    
         
             
                      a.attr['id'] = "#{sections.attr['id']}-#{id}"
         
     | 
| 
         @@ -395,7 +403,7 @@ module Kramdown 
     | 
|
| 
       395 
403 
     | 
    
         
             
                      li.children << Element.new(type)
         
     | 
| 
       396 
404 
     | 
    
         | 
| 
       397 
405 
     | 
    
         
             
                      success = false
         
     | 
| 
       398 
     | 
    
         
            -
                       
     | 
| 
      
 406 
     | 
    
         
            +
                      until success
         
     | 
| 
       399 
407 
     | 
    
         
             
                        if stack.empty?
         
     | 
| 
       400 
408 
     | 
    
         
             
                          sections.children << li
         
     | 
| 
       401 
409 
     | 
    
         
             
                          stack << li
         
     | 
| 
         @@ -406,13 +414,13 @@ module Kramdown 
     | 
|
| 
       406 
414 
     | 
    
         
             
                          success = true
         
     | 
| 
       407 
415 
     | 
    
         
             
                        else
         
     | 
| 
       408 
416 
     | 
    
         
             
                          item = stack.pop
         
     | 
| 
       409 
     | 
    
         
            -
                          item.children.pop  
     | 
| 
      
 417 
     | 
    
         
            +
                          item.children.pop if item.children.last.children.empty?
         
     | 
| 
       410 
418 
     | 
    
         
             
                        end
         
     | 
| 
       411 
419 
     | 
    
         
             
                      end
         
     | 
| 
       412 
420 
     | 
    
         
             
                    end
         
     | 
| 
       413 
     | 
    
         
            -
                     
     | 
| 
      
 421 
     | 
    
         
            +
                    until stack.empty?
         
     | 
| 
       414 
422 
     | 
    
         
             
                      item = stack.pop
         
     | 
| 
       415 
     | 
    
         
            -
                      item.children.pop  
     | 
| 
      
 423 
     | 
    
         
            +
                      item.children.pop if item.children.last.children.empty?
         
     | 
| 
       416 
424 
     | 
    
         
             
                    end
         
     | 
| 
       417 
425 
     | 
    
         
             
                    sections
         
     | 
| 
       418 
426 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -442,9 +450,9 @@ module Kramdown 
     | 
|
| 
       442 
450 
     | 
    
         | 
| 
       443 
451 
     | 
    
         
             
                  # Obfuscate the +text+ by using HTML entities.
         
     | 
| 
       444 
452 
     | 
    
         
             
                  def obfuscate(text)
         
     | 
| 
       445 
     | 
    
         
            -
                    result =  
     | 
| 
      
 453 
     | 
    
         
            +
                    result = +''
         
     | 
| 
       446 
454 
     | 
    
         
             
                    text.each_byte do |b|
         
     | 
| 
       447 
     | 
    
         
            -
                      result << (b > 128 ? b.chr : "&#%03d;"  
     | 
| 
      
 455 
     | 
    
         
            +
                      result << (b > 128 ? b.chr : sprintf("&#%03d;", b))
         
     | 
| 
       448 
456 
     | 
    
         
             
                    end
         
     | 
| 
       449 
457 
     | 
    
         
             
                    result.force_encoding(text.encoding)
         
     | 
| 
       450 
458 
     | 
    
         
             
                    result
         
     | 
| 
         @@ -460,7 +468,7 @@ module Kramdown 
     | 
|
| 
       460 
468 
     | 
    
         
             
                    backlink_text = escape_html(@options[:footnote_backlink], :text)
         
     | 
| 
       461 
469 
     | 
    
         
             
                    while i < @footnotes.length
         
     | 
| 
       462 
470 
     | 
    
         
             
                      name, data, _, repeat = *@footnotes[i]
         
     | 
| 
       463 
     | 
    
         
            -
                      li = Element.new(:li, nil,  
     | 
| 
      
 471 
     | 
    
         
            +
                      li = Element.new(:li, nil, 'id' => "fn:#{name}")
         
     | 
| 
       464 
472 
     | 
    
         
             
                      li.children = Marshal.load(Marshal.dump(data.children))
         
     | 
| 
       465 
473 
     | 
    
         | 
| 
       466 
474 
     | 
    
         
             
                      para = nil
         
     | 
| 
         @@ -480,16 +488,23 @@ module Kramdown 
     | 
|
| 
       480 
488 
     | 
    
         | 
| 
       481 
489 
     | 
    
         
             
                      unless @options[:footnote_backlink].empty?
         
     | 
| 
       482 
490 
     | 
    
         
             
                        nbsp = entity_to_str(ENTITY_NBSP)
         
     | 
| 
       483 
     | 
    
         
            -
                         
     | 
| 
      
 491 
     | 
    
         
            +
                        value = sprintf(FOOTNOTE_BACKLINK_FMT, (insert_space ? nbsp : ''), name, backlink_text)
         
     | 
| 
      
 492 
     | 
    
         
            +
                        para.children << Element.new(:raw, value)
         
     | 
| 
       484 
493 
     | 
    
         
             
                        (1..repeat).each do |index|
         
     | 
| 
       485 
     | 
    
         
            -
                           
     | 
| 
      
 494 
     | 
    
         
            +
                          value = sprintf(FOOTNOTE_BACKLINK_FMT, nbsp, "#{name}:#{index}",
         
     | 
| 
      
 495 
     | 
    
         
            +
                                          "#{backlink_text}<sup>#{index + 1}</sup>")
         
     | 
| 
      
 496 
     | 
    
         
            +
                          para.children << Element.new(:raw, value)
         
     | 
| 
       486 
497 
     | 
    
         
             
                        end
         
     | 
| 
       487 
498 
     | 
    
         
             
                      end
         
     | 
| 
       488 
499 
     | 
    
         | 
| 
       489 
500 
     | 
    
         
             
                      ol.children << Element.new(:raw, convert(li, 4))
         
     | 
| 
       490 
501 
     | 
    
         
             
                      i += 1
         
     | 
| 
       491 
502 
     | 
    
         
             
                    end
         
     | 
| 
       492 
     | 
    
         
            -
                     
     | 
| 
      
 503 
     | 
    
         
            +
                    if ol.children.empty?
         
     | 
| 
      
 504 
     | 
    
         
            +
                      ''
         
     | 
| 
      
 505 
     | 
    
         
            +
                    else
         
     | 
| 
      
 506 
     | 
    
         
            +
                      format_as_indented_block_html('div', {class: "footnotes"}, convert(ol, 2), 0)
         
     | 
| 
      
 507 
     | 
    
         
            +
                    end
         
     | 
| 
       493 
508 
     | 
    
         
             
                  end
         
     | 
| 
       494 
509 
     | 
    
         | 
| 
       495 
510 
     | 
    
         
             
                end
         
     |