commonmarker 0.23.1 → 0.23.5
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 commonmarker might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Rakefile +56 -55
- data/bin/commonmarker +2 -7
- data/commonmarker.gemspec +27 -26
- data/ext/commonmarker/blocks.c +13 -2
- data/ext/commonmarker/cmark-gfm_version.h +2 -2
- data/ext/commonmarker/commonmark.c +14 -4
- data/ext/commonmarker/commonmarker.c +30 -44
- data/ext/commonmarker/ext_scanners.c +360 -640
- data/ext/commonmarker/footnotes.c +23 -0
- data/ext/commonmarker/footnotes.h +2 -0
- data/ext/commonmarker/html.c +40 -19
- data/ext/commonmarker/inlines.c +69 -11
- data/ext/commonmarker/node.h +7 -0
- data/ext/commonmarker/scanners.c +2438 -2450
- data/ext/commonmarker/table.c +98 -53
- data/lib/commonmarker/config.rb +1 -1
- data/lib/commonmarker/node/inspect.rb +8 -18
- data/lib/commonmarker/node.rb +6 -6
- data/lib/commonmarker/renderer/html_renderer.rb +37 -37
- data/lib/commonmarker/renderer.rb +5 -5
- data/lib/commonmarker/version.rb +1 -1
- data/lib/commonmarker.rb +9 -11
- metadata +6 -57
- data/test/benchmark.rb +0 -32
- data/test/fixtures/curly.md +0 -1
- data/test/fixtures/dingus.md +0 -10
- data/test/fixtures/strong.md +0 -1
- data/test/fixtures/table.md +0 -10
- data/test/test_attributes.rb +0 -24
- data/test/test_basics.rb +0 -35
- data/test/test_commands.rb +0 -72
- data/test/test_commonmark.rb +0 -36
- data/test/test_doc.rb +0 -130
- data/test/test_encoding.rb +0 -23
- data/test/test_extensions.rb +0 -116
- data/test/test_footnotes.rb +0 -48
- data/test/test_gc.rb +0 -47
- data/test/test_helper.rb +0 -71
- data/test/test_linebreaks.rb +0 -15
- data/test/test_maliciousness.rb +0 -262
- data/test/test_node.rb +0 -89
- data/test/test_options.rb +0 -37
- data/test/test_pathological_inputs.rb +0 -94
- data/test/test_plaintext.rb +0 -46
- data/test/test_renderer.rb +0 -47
- data/test/test_smartpunct.rb +0 -27
- data/test/test_spec.rb +0 -30
- data/test/test_tasklists.rb +0 -43
- data/test/test_xml.rb +0 -107
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: commonmarker
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.23. | 
| 4 | 
            +
              version: 0.23.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Garen Torikian
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire:
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2022-05-31 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: awesome_print
         | 
| @@ -229,36 +229,11 @@ files: | |
| 229 229 | 
             
            - lib/commonmarker/renderer.rb
         | 
| 230 230 | 
             
            - lib/commonmarker/renderer/html_renderer.rb
         | 
| 231 231 | 
             
            - lib/commonmarker/version.rb
         | 
| 232 | 
            -
            - test/benchmark.rb
         | 
| 233 | 
            -
            - test/fixtures/curly.md
         | 
| 234 | 
            -
            - test/fixtures/dingus.md
         | 
| 235 | 
            -
            - test/fixtures/strong.md
         | 
| 236 | 
            -
            - test/fixtures/table.md
         | 
| 237 | 
            -
            - test/test_attributes.rb
         | 
| 238 | 
            -
            - test/test_basics.rb
         | 
| 239 | 
            -
            - test/test_commands.rb
         | 
| 240 | 
            -
            - test/test_commonmark.rb
         | 
| 241 | 
            -
            - test/test_doc.rb
         | 
| 242 | 
            -
            - test/test_encoding.rb
         | 
| 243 | 
            -
            - test/test_extensions.rb
         | 
| 244 | 
            -
            - test/test_footnotes.rb
         | 
| 245 | 
            -
            - test/test_gc.rb
         | 
| 246 | 
            -
            - test/test_helper.rb
         | 
| 247 | 
            -
            - test/test_linebreaks.rb
         | 
| 248 | 
            -
            - test/test_maliciousness.rb
         | 
| 249 | 
            -
            - test/test_node.rb
         | 
| 250 | 
            -
            - test/test_options.rb
         | 
| 251 | 
            -
            - test/test_pathological_inputs.rb
         | 
| 252 | 
            -
            - test/test_plaintext.rb
         | 
| 253 | 
            -
            - test/test_renderer.rb
         | 
| 254 | 
            -
            - test/test_smartpunct.rb
         | 
| 255 | 
            -
            - test/test_spec.rb
         | 
| 256 | 
            -
            - test/test_tasklists.rb
         | 
| 257 | 
            -
            - test/test_xml.rb
         | 
| 258 232 | 
             
            homepage: https://github.com/gjtorikian/commonmarker
         | 
| 259 233 | 
             
            licenses:
         | 
| 260 234 | 
             
            - MIT
         | 
| 261 | 
            -
            metadata: | 
| 235 | 
            +
            metadata:
         | 
| 236 | 
            +
              rubygems_mfa_required: 'true'
         | 
| 262 237 | 
             
            post_install_message:
         | 
| 263 238 | 
             
            rdoc_options:
         | 
| 264 239 | 
             
            - "-x"
         | 
| @@ -280,34 +255,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 280 255 | 
             
                - !ruby/object:Gem::Version
         | 
| 281 256 | 
             
                  version: '0'
         | 
| 282 257 | 
             
            requirements: []
         | 
| 283 | 
            -
            rubygems_version: 3. | 
| 258 | 
            +
            rubygems_version: 3.3.13
         | 
| 284 259 | 
             
            signing_key:
         | 
| 285 260 | 
             
            specification_version: 4
         | 
| 286 261 | 
             
            summary: CommonMark parser and renderer. Written in C, wrapped in Ruby.
         | 
| 287 | 
            -
            test_files:
         | 
| 288 | 
            -
            - test/test_attributes.rb
         | 
| 289 | 
            -
            - test/test_linebreaks.rb
         | 
| 290 | 
            -
            - test/test_doc.rb
         | 
| 291 | 
            -
            - test/test_plaintext.rb
         | 
| 292 | 
            -
            - test/test_pathological_inputs.rb
         | 
| 293 | 
            -
            - test/test_node.rb
         | 
| 294 | 
            -
            - test/test_maliciousness.rb
         | 
| 295 | 
            -
            - test/test_commands.rb
         | 
| 296 | 
            -
            - test/test_tasklists.rb
         | 
| 297 | 
            -
            - test/test_commonmark.rb
         | 
| 298 | 
            -
            - test/test_encoding.rb
         | 
| 299 | 
            -
            - test/test_smartpunct.rb
         | 
| 300 | 
            -
            - test/test_spec.rb
         | 
| 301 | 
            -
            - test/test_footnotes.rb
         | 
| 302 | 
            -
            - test/test_extensions.rb
         | 
| 303 | 
            -
            - test/fixtures/dingus.md
         | 
| 304 | 
            -
            - test/fixtures/strong.md
         | 
| 305 | 
            -
            - test/fixtures/table.md
         | 
| 306 | 
            -
            - test/fixtures/curly.md
         | 
| 307 | 
            -
            - test/test_helper.rb
         | 
| 308 | 
            -
            - test/test_options.rb
         | 
| 309 | 
            -
            - test/benchmark.rb
         | 
| 310 | 
            -
            - test/test_xml.rb
         | 
| 311 | 
            -
            - test/test_basics.rb
         | 
| 312 | 
            -
            - test/test_renderer.rb
         | 
| 313 | 
            -
            - test/test_gc.rb
         | 
| 262 | 
            +
            test_files: []
         | 
    
        data/test/benchmark.rb
    DELETED
    
    | @@ -1,32 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'commonmarker'
         | 
| 4 | 
            -
            require 'github/markdown'
         | 
| 5 | 
            -
            require 'redcarpet'
         | 
| 6 | 
            -
            require 'kramdown'
         | 
| 7 | 
            -
            require 'benchmark'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            def dobench(name, &blk)
         | 
| 10 | 
            -
              puts name
         | 
| 11 | 
            -
              puts Benchmark.measure(&blk)
         | 
| 12 | 
            -
            end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            benchinput = File.open('test/benchinput.md', 'r').read
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            printf("input size = %<bytes>d bytes\n\n", benchinput.bytesize)
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            dobench('redcarpet') do
         | 
| 19 | 
            -
              Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: false, tables: false).render(benchinput)
         | 
| 20 | 
            -
            end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            dobench('commonmarker with to_html') do
         | 
| 23 | 
            -
              CommonMarker.render_html(benchinput)
         | 
| 24 | 
            -
            end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            dobench('commonmarker with ruby HtmlRenderer') do
         | 
| 27 | 
            -
              CommonMarker::HtmlRenderer.new.render(CommonMarker.render_doc(benchinput))
         | 
| 28 | 
            -
            end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            dobench('kramdown') do
         | 
| 31 | 
            -
              Kramdown::Document.new(benchinput).to_html(benchinput)
         | 
| 32 | 
            -
            end
         | 
    
        data/test/fixtures/curly.md
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            This curly quote “makes commonmarker throw an exception”.
         | 
    
        data/test/fixtures/dingus.md
    DELETED
    
    
    
        data/test/fixtures/strong.md
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            I am **strong**
         | 
    
        data/test/fixtures/table.md
    DELETED
    
    
    
        data/test/test_attributes.rb
    DELETED
    
    | @@ -1,24 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestAttributes < Minitest::Test
         | 
| 6 | 
            -
              def setup
         | 
| 7 | 
            -
                contents = fixtures_file('dingus.md')
         | 
| 8 | 
            -
                @doc = CommonMarker.render_doc(contents.strip)
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              def test_sourcepos
         | 
| 12 | 
            -
                sourcepos = []
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                @doc.walk do |node|
         | 
| 15 | 
            -
                  sourcepos << node.sourcepos
         | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                sourcepos.delete_if { |h| h.values.all?(&:zero?) }
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                result = [{ start_line: 1, start_column: 1, end_line: 10, end_column: 12 }, { start_line: 1, start_column: 1, end_line: 1, end_column: 17 }, { start_line: 1, start_column: 4, end_line: 1, end_column: 17 }, { start_line: 3, start_column: 1, end_line: 5, end_column: 36 }, { start_line: 3, start_column: 1, end_line: 3, end_column: 55 }, { start_line: 4, start_column: 1, end_line: 4, end_column: 53 }, { start_line: 4, start_column: 2, end_line: 4, end_column: 14 }, { start_line: 4, start_column: 54, end_line: 4, end_column: 58 }, { start_line: 5, start_column: 1, end_line: 5, end_column: 36 }, { start_line: 7, start_column: 1, end_line: 10, end_column: 12 }, { start_line: 7, start_column: 1, end_line: 7, end_column: 11 }, { start_line: 7, start_column: 4, end_line: 7, end_column: 11 }, { start_line: 7, start_column: 4, end_line: 7, end_column: 11 }, { start_line: 8, start_column: 1, end_line: 10, end_column: 12 }, { start_line: 8, start_column: 4, end_line: 8, end_column: 11 }, { start_line: 8, start_column: 4, end_line: 8, end_column: 11 }, { start_line: 9, start_column: 4, end_line: 10, end_column: 12 }, { start_line: 9, start_column: 4, end_line: 9, end_column: 12 }, { start_line: 9, start_column: 6, end_line: 9, end_column: 12 }, { start_line: 9, start_column: 6, end_line: 9, end_column: 12 }, { start_line: 10, start_column: 4, end_line: 10, end_column: 12 }, { start_line: 10, start_column: 6, end_line: 10, end_column: 12 }, { start_line: 10, start_column: 6, end_line: 10, end_column: 12 }]
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                assert_equal result, sourcepos
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
            end
         | 
    
        data/test/test_basics.rb
    DELETED
    
    | @@ -1,35 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestBasics < Minitest::Test
         | 
| 6 | 
            -
              def setup
         | 
| 7 | 
            -
                @doc = CommonMarker.render_doc('Hi *there*')
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              def test_to_html
         | 
| 11 | 
            -
                assert_equal "<p>Hi <em>there</em></p>\n", @doc.to_html
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              def test_markdown_to_html
         | 
| 15 | 
            -
                html = CommonMarker.render_html('Hi *there*')
         | 
| 16 | 
            -
                assert_equal "<p>Hi <em>there</em></p>\n", html
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              # basic test that just checks if every option is accepted & no errors are thrown
         | 
| 20 | 
            -
              def test_accept_every_option
         | 
| 21 | 
            -
                text = "Hello **world** -- how are _you_ today? I'm ~~fine~~, ~yourself~?"
         | 
| 22 | 
            -
                parse_opt = [:SOURCEPOS, :UNSAFE, :VALIDATE_UTF8, :SMART, :LIBERAL_HTML_TAG, :FOOTNOTES, :STRIKETHROUGH_DOUBLE_TILDE]
         | 
| 23 | 
            -
                render_opt = parse_opt + [:HARDBREAKS, :NOBREAKS, :GITHUB_PRE_LANG, :TABLE_PREFER_STYLE_ATTRIBUTES, :FULL_INFO_STRING]
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                extensions = %i[table tasklist strikethrough autolink tagfilter]
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                assert_equal "<p>Hello <strong>world</strong> – how are <em>you</em> today? I’m <del>fine</del>, ~yourself~?</p>\n", CommonMarker.render_doc(text, parse_opt, extensions).to_html
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                # note how tho the doc returned has sourcepos info, by default the renderer
         | 
| 30 | 
            -
                # won't emit it. for that we need to pass in the render opt
         | 
| 31 | 
            -
                assert_equal "<p data-sourcepos=\"1:1-1:65\">Hello <strong>world</strong> – how are <em>you</em> today? I’m <del>fine</del>, ~yourself~?</p>\n", CommonMarker.render_doc(text, parse_opt, extensions).to_html(render_opt, extensions)
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                assert_equal "<p data-sourcepos=\"1:1-1:65\">Hello <strong>world</strong> – how are <em>you</em> today? I’m <del>fine</del>, ~yourself~?</p>\n", CommonMarker.render_html(text, parse_opt, extensions)
         | 
| 34 | 
            -
              end
         | 
| 35 | 
            -
            end
         | 
    
        data/test/test_commands.rb
    DELETED
    
    | @@ -1,72 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestCommands < Minitest::Test
         | 
| 6 | 
            -
              def test_basic
         | 
| 7 | 
            -
                out = make_bin('strong.md')
         | 
| 8 | 
            -
                assert_equal('<p>I am <strong>strong</strong></p>', out)
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              def test_does_not_have_extensions
         | 
| 12 | 
            -
                out = make_bin('table.md')
         | 
| 13 | 
            -
                assert_includes out, '| a'
         | 
| 14 | 
            -
                refute_includes out, '<p><del>hi</del>'
         | 
| 15 | 
            -
                refute_includes out, '<table> <tr> <th> a </th> <td> c </td>'
         | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              def test_understands_extensions
         | 
| 19 | 
            -
                out = make_bin('table.md', '--extension=table')
         | 
| 20 | 
            -
                refute_includes out, '| a'
         | 
| 21 | 
            -
                refute_includes out, '<p><del>hi</del>'
         | 
| 22 | 
            -
                %w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert_includes out, html }
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              def test_understands_multiple_extensions
         | 
| 26 | 
            -
                out = make_bin('table.md', '--extension=table,strikethrough')
         | 
| 27 | 
            -
                refute_includes out, '| a'
         | 
| 28 | 
            -
                assert_includes out, '<p><del>hi</del>'
         | 
| 29 | 
            -
                %w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert_includes out, html }
         | 
| 30 | 
            -
              end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
              def test_understands_html_format_with_renderer_and_extensions
         | 
| 33 | 
            -
                out = make_bin('table.md', '--to=html --extension=table,strikethrough --html-renderer')
         | 
| 34 | 
            -
                refute_includes out, '| a'
         | 
| 35 | 
            -
                assert_includes out, '<p><del>hi</del>'
         | 
| 36 | 
            -
                %w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert_includes out, html }
         | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              def test_understands_xml_format
         | 
| 40 | 
            -
                out = make_bin('strong.md', '--to=xml')
         | 
| 41 | 
            -
                assert_includes out, '<?xml version="1.0" encoding="UTF-8"?>'
         | 
| 42 | 
            -
                assert_includes out, '<text xml:space="preserve">strong</text>'
         | 
| 43 | 
            -
              end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
              def test_understands_commonmark_format
         | 
| 46 | 
            -
                out = make_bin('strong.md', '--to=commonmark')
         | 
| 47 | 
            -
                assert_equal('I am **strong**', out)
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
              def test_understands_plaintext_format
         | 
| 51 | 
            -
                out = make_bin('strong.md', '--to=plaintext')
         | 
| 52 | 
            -
                assert_equal('I am strong', out)
         | 
| 53 | 
            -
              end
         | 
| 54 | 
            -
             | 
| 55 | 
            -
              def test_aborts_invalid_format
         | 
| 56 | 
            -
                _out, err = capture_subprocess_io do
         | 
| 57 | 
            -
                  make_bin('strong.md', '--to=unknown')
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                assert_match "format 'unknown' not found", err
         | 
| 61 | 
            -
              end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
              def test_aborts_format_and_html_renderer_combinations
         | 
| 64 | 
            -
                (CommonMarker::Config::OPTS[:format] - [:html]).each do |format|
         | 
| 65 | 
            -
                  _out, err = capture_subprocess_io do
         | 
| 66 | 
            -
                    make_bin('strong.md', "--to=#{format} --html-renderer")
         | 
| 67 | 
            -
                  end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                  assert_match "format '#{format}' does not support using the HtmlRenderer renderer", err
         | 
| 70 | 
            -
                end
         | 
| 71 | 
            -
              end
         | 
| 72 | 
            -
            end
         | 
    
        data/test/test_commonmark.rb
    DELETED
    
    | @@ -1,36 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestCommonmark < Minitest::Test
         | 
| 6 | 
            -
              HTML_COMMENT = /<!--.*?-->\s?/.freeze
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              def setup
         | 
| 9 | 
            -
                @markdown = <<~MD
         | 
| 10 | 
            -
                  Hi *there*!
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  1. I am a numeric list.
         | 
| 13 | 
            -
                  2. I continue the list.
         | 
| 14 | 
            -
                  * Suddenly, an unordered list!
         | 
| 15 | 
            -
                  * What fun!
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  Okay, _enough_.
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  | a   | b   |
         | 
| 20 | 
            -
                  | --- | --- |
         | 
| 21 | 
            -
                  | c   | d   |
         | 
| 22 | 
            -
                MD
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              def render_doc(doc)
         | 
| 26 | 
            -
                CommonMarker.render_doc(doc, :DEFAULT, %i[table])
         | 
| 27 | 
            -
              end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              def test_to_commonmark
         | 
| 30 | 
            -
                compare = render_doc(@markdown).to_commonmark
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                assert_equal \
         | 
| 33 | 
            -
                  render_doc(@markdown).to_html.squeeze(' ').gsub(HTML_COMMENT, ''),
         | 
| 34 | 
            -
                  render_doc(compare).to_html.squeeze(' ').gsub(HTML_COMMENT, '')
         | 
| 35 | 
            -
              end
         | 
| 36 | 
            -
            end
         | 
    
        data/test/test_doc.rb
    DELETED
    
    | @@ -1,130 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestDocNode < Minitest::Test
         | 
| 6 | 
            -
              def setup
         | 
| 7 | 
            -
                @doc = CommonMarker.render_doc('Hi *there*. This has __many nodes__!')
         | 
| 8 | 
            -
                @first_child = @doc.first_child
         | 
| 9 | 
            -
                @last_child = @doc.last_child
         | 
| 10 | 
            -
                @link = CommonMarker.render_doc('[GitHub](https://www.github.com)').first_child.first_child
         | 
| 11 | 
            -
                @image = CommonMarker.render_doc('')
         | 
| 12 | 
            -
                @image = @image.first_child.first_child
         | 
| 13 | 
            -
                @header = CommonMarker.render_doc('### Header Three').first_child
         | 
| 14 | 
            -
                @ul_list = CommonMarker.render_doc("* Bullet\n*Bullet").first_child
         | 
| 15 | 
            -
                @ol_list = CommonMarker.render_doc("1. One\n2. Two").first_child
         | 
| 16 | 
            -
                @fence = CommonMarker.render_doc("``` ruby\nputs 'wow'\n```").first_child
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              def test_get_type
         | 
| 20 | 
            -
                assert_equal(:document, @doc.type)
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              def test_get_type_string
         | 
| 24 | 
            -
                assert_equal('document', @doc.type_string)
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
              def test_get_first_child
         | 
| 28 | 
            -
                assert_equal(:paragraph, @first_child.type)
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              def test_get_next
         | 
| 32 | 
            -
                assert_equal(:emph, @first_child.first_child.next.type)
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
              def test_insert_before
         | 
| 36 | 
            -
                paragraph = Node.new(:paragraph)
         | 
| 37 | 
            -
                assert(@first_child.insert_before(paragraph))
         | 
| 38 | 
            -
                assert_match "<p></p>\n<p>Hi <em>there</em>.", @doc.to_html
         | 
| 39 | 
            -
              end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
              def test_insert_after
         | 
| 42 | 
            -
                paragraph = Node.new(:paragraph)
         | 
| 43 | 
            -
                assert(@first_child.insert_after(paragraph))
         | 
| 44 | 
            -
                assert_match "<strong>many nodes</strong>!</p>\n<p></p>\n", @doc.to_html
         | 
| 45 | 
            -
              end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
              def test_prepend_child
         | 
| 48 | 
            -
                code = Node.new(:code)
         | 
| 49 | 
            -
                assert(@first_child.prepend_child(code))
         | 
| 50 | 
            -
                assert_match '<p><code></code>Hi <em>there</em>.', @doc.to_html
         | 
| 51 | 
            -
              end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
              def test_append_child
         | 
| 54 | 
            -
                strong = Node.new(:strong)
         | 
| 55 | 
            -
                assert(@first_child.append_child(strong))
         | 
| 56 | 
            -
                assert_match "!<strong></strong></p>\n", @doc.to_html
         | 
| 57 | 
            -
              end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
              def test_get_last_child
         | 
| 60 | 
            -
                assert_equal(:paragraph, @last_child.type)
         | 
| 61 | 
            -
              end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
              def test_get_parent
         | 
| 64 | 
            -
                assert_equal(:paragraph, @first_child.first_child.next.parent.type)
         | 
| 65 | 
            -
              end
         | 
| 66 | 
            -
             | 
| 67 | 
            -
              def test_get_previous
         | 
| 68 | 
            -
                assert_equal(:text, @first_child.first_child.next.previous.type)
         | 
| 69 | 
            -
              end
         | 
| 70 | 
            -
             | 
| 71 | 
            -
              def test_get_url
         | 
| 72 | 
            -
                assert_equal('https://www.github.com', @link.url)
         | 
| 73 | 
            -
              end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
              def test_set_url
         | 
| 76 | 
            -
                assert_equal('https://www.mozilla.org', @link.url = 'https://www.mozilla.org')
         | 
| 77 | 
            -
              end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
              def test_get_title
         | 
| 80 | 
            -
                assert_equal('Favicon', @image.title)
         | 
| 81 | 
            -
              end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
              def test_set_title
         | 
| 84 | 
            -
                assert_equal('Octocat', @image.title = 'Octocat')
         | 
| 85 | 
            -
              end
         | 
| 86 | 
            -
             | 
| 87 | 
            -
              def test_get_header_level
         | 
| 88 | 
            -
                assert_equal(3, @header.header_level)
         | 
| 89 | 
            -
              end
         | 
| 90 | 
            -
             | 
| 91 | 
            -
              def test_set_header_level
         | 
| 92 | 
            -
                assert_equal(6, @header.header_level = 6)
         | 
| 93 | 
            -
              end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
              def test_get_list_type
         | 
| 96 | 
            -
                assert_equal(:bullet_list, @ul_list.list_type)
         | 
| 97 | 
            -
                assert_equal(:ordered_list, @ol_list.list_type)
         | 
| 98 | 
            -
              end
         | 
| 99 | 
            -
             | 
| 100 | 
            -
              def test_set_list_type
         | 
| 101 | 
            -
                assert_equal(:ordered_list, @ul_list.list_type = :ordered_list)
         | 
| 102 | 
            -
                assert_equal(:bullet_list, @ol_list.list_type = :bullet_list)
         | 
| 103 | 
            -
              end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
              def test_get_list_start
         | 
| 106 | 
            -
                assert_equal(1, @ol_list.list_start)
         | 
| 107 | 
            -
              end
         | 
| 108 | 
            -
             | 
| 109 | 
            -
              def test_set_list_start
         | 
| 110 | 
            -
                assert_equal(8, @ol_list.list_start = 8)
         | 
| 111 | 
            -
              end
         | 
| 112 | 
            -
             | 
| 113 | 
            -
              def test_get_list_tight
         | 
| 114 | 
            -
                assert(@ul_list.list_tight)
         | 
| 115 | 
            -
                assert(@ol_list.list_tight)
         | 
| 116 | 
            -
              end
         | 
| 117 | 
            -
             | 
| 118 | 
            -
              def test_set_list_tight
         | 
| 119 | 
            -
                refute(@ul_list.list_tight = false)
         | 
| 120 | 
            -
                refute(@ol_list.list_tight = false)
         | 
| 121 | 
            -
              end
         | 
| 122 | 
            -
             | 
| 123 | 
            -
              def test_get_fence_info
         | 
| 124 | 
            -
                assert_equal('ruby', @fence.fence_info)
         | 
| 125 | 
            -
              end
         | 
| 126 | 
            -
             | 
| 127 | 
            -
              def test_set_fence_info
         | 
| 128 | 
            -
                assert_equal('javascript', @fence.fence_info = 'javascript')
         | 
| 129 | 
            -
              end
         | 
| 130 | 
            -
            end
         | 
    
        data/test/test_encoding.rb
    DELETED
    
    | @@ -1,23 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestEncoding < Minitest::Test
         | 
| 6 | 
            -
              # see http://git.io/vq4FR
         | 
| 7 | 
            -
              def test_encoding
         | 
| 8 | 
            -
                contents = fixtures_file('curly.md')
         | 
| 9 | 
            -
                doc = CommonMarker.render_doc(contents, :SMART)
         | 
| 10 | 
            -
                render = doc.to_html
         | 
| 11 | 
            -
                assert_equal('<p>This curly quote “makes commonmarker throw an exception”.</p>', render.rstrip)
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                render = doc.to_xml
         | 
| 14 | 
            -
                assert_includes(render, '<text xml:space="preserve">This curly quote “makes commonmarker throw an exception”.</text>')
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
              def test_string_content_is_utf8
         | 
| 18 | 
            -
                doc = CommonMarker.render_doc('Hi *there*')
         | 
| 19 | 
            -
                text = doc.first_child.last_child.first_child
         | 
| 20 | 
            -
                assert_equal('there', text.string_content)
         | 
| 21 | 
            -
                assert_equal('UTF-8', text.string_content.encoding.name)
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
            end
         | 
    
        data/test/test_extensions.rb
    DELETED
    
    | @@ -1,116 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestExtensions < Minitest::Test
         | 
| 6 | 
            -
              def setup
         | 
| 7 | 
            -
                @markdown = fixtures_file('table.md')
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              def test_uses_specified_extensions
         | 
| 11 | 
            -
                CommonMarker.render_html(@markdown, :DEFAULT, %i[]).tap do |out|
         | 
| 12 | 
            -
                  assert_includes out, '| a'
         | 
| 13 | 
            -
                  assert_includes out, '| <strong>x</strong>'
         | 
| 14 | 
            -
                  assert_includes out, '~~hi~~'
         | 
| 15 | 
            -
                end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                CommonMarker.render_html(@markdown, :DEFAULT, %i[table]).tap do |out|
         | 
| 18 | 
            -
                  refute_includes out, '| a'
         | 
| 19 | 
            -
                  %w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert_includes out, html }
         | 
| 20 | 
            -
                  assert_includes out, '~~hi~~'
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                CommonMarker.render_html(@markdown, :DEFAULT, %i[strikethrough]).tap do |out|
         | 
| 24 | 
            -
                  assert_includes out, '| a'
         | 
| 25 | 
            -
                  refute_includes out, '~~hi~~'
         | 
| 26 | 
            -
                  assert_includes out, '<del>hi</del>'
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                doc = CommonMarker.render_doc('~a~ ~~b~~ ~~~c~~~', :STRIKETHROUGH_DOUBLE_TILDE, [:strikethrough])
         | 
| 30 | 
            -
                assert_equal("<p>~a~ <del>b</del> ~~~c~~~</p>\n", doc.to_html)
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                html = CommonMarker.render_html('~a~ ~~b~~ ~~~c~~~', :STRIKETHROUGH_DOUBLE_TILDE, [:strikethrough])
         | 
| 33 | 
            -
                assert_equal("<p>~a~ <del>b</del> ~~~c~~~</p>\n", html)
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                CommonMarker.render_html(@markdown, :DEFAULT, %i[table strikethrough]).tap do |out|
         | 
| 36 | 
            -
                  refute_includes out, '| a'
         | 
| 37 | 
            -
                  refute_includes out, '| <strong>x</strong>'
         | 
| 38 | 
            -
                  refute_includes out, '~~hi~~'
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
              end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
              def test_extensions_with_renderers
         | 
| 43 | 
            -
                doc = CommonMarker.render_doc(@markdown, :DEFAULT, %i[table])
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                doc.to_html.tap do |out|
         | 
| 46 | 
            -
                  refute_includes out, '| a'
         | 
| 47 | 
            -
                  %w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert_includes out, html }
         | 
| 48 | 
            -
                  assert_includes out, '~~hi~~'
         | 
| 49 | 
            -
                end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                HtmlRenderer.new.render(doc).tap do |out|
         | 
| 52 | 
            -
                  refute_includes out, '| a'
         | 
| 53 | 
            -
                  %w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert_includes out, html }
         | 
| 54 | 
            -
                  assert_includes out, '~~hi~~'
         | 
| 55 | 
            -
                end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                doc = CommonMarker.render_doc('~a~ ~~b~~ ~~~c~~~', :STRIKETHROUGH_DOUBLE_TILDE, [:strikethrough])
         | 
| 58 | 
            -
                assert_equal("<p>~a~ <del>b</del> ~~~c~~~</p>\n", HtmlRenderer.new.render(doc))
         | 
| 59 | 
            -
              end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
              def test_bad_extension_specifications
         | 
| 62 | 
            -
                assert_raises(TypeError) { CommonMarker.render_html(@markdown, :DEFAULT, 'nope') }
         | 
| 63 | 
            -
                assert_raises(TypeError) { CommonMarker.render_html(@markdown, :DEFAULT, ['table']) }
         | 
| 64 | 
            -
                assert_raises(ArgumentError) { CommonMarker.render_html(@markdown, :DEFAULT, %i[table bad]) }
         | 
| 65 | 
            -
              end
         | 
| 66 | 
            -
             | 
| 67 | 
            -
              def test_comments_are_kept_as_expected
         | 
| 68 | 
            -
                assert_equal "<!--hello--> <blah> <xmp>\n",
         | 
| 69 | 
            -
                             CommonMarker.render_html("<!--hello--> <blah> <xmp>\n", :UNSAFE, %i[tagfilter])
         | 
| 70 | 
            -
              end
         | 
| 71 | 
            -
             | 
| 72 | 
            -
              def test_table_prefer_style_attributes
         | 
| 73 | 
            -
                assert_equal(<<~HTML, CommonMarker.render_html(<<~MD, :TABLE_PREFER_STYLE_ATTRIBUTES, %i[table]))
         | 
| 74 | 
            -
                  <table>
         | 
| 75 | 
            -
                  <thead>
         | 
| 76 | 
            -
                  <tr>
         | 
| 77 | 
            -
                  <th style="text-align: left">aaa</th>
         | 
| 78 | 
            -
                  <th>bbb</th>
         | 
| 79 | 
            -
                  <th style="text-align: center">ccc</th>
         | 
| 80 | 
            -
                  <th>ddd</th>
         | 
| 81 | 
            -
                  <th style="text-align: right">eee</th>
         | 
| 82 | 
            -
                  </tr>
         | 
| 83 | 
            -
                  </thead>
         | 
| 84 | 
            -
                  <tbody>
         | 
| 85 | 
            -
                  <tr>
         | 
| 86 | 
            -
                  <td style="text-align: left">fff</td>
         | 
| 87 | 
            -
                  <td>ggg</td>
         | 
| 88 | 
            -
                  <td style="text-align: center">hhh</td>
         | 
| 89 | 
            -
                  <td>iii</td>
         | 
| 90 | 
            -
                  <td style="text-align: right">jjj</td>
         | 
| 91 | 
            -
                  </tr>
         | 
| 92 | 
            -
                  </tbody>
         | 
| 93 | 
            -
                  </table>
         | 
| 94 | 
            -
                HTML
         | 
| 95 | 
            -
                  aaa | bbb | ccc | ddd | eee
         | 
| 96 | 
            -
                  :-- | --- | :-: | --- | --:
         | 
| 97 | 
            -
                  fff | ggg | hhh | iii | jjj
         | 
| 98 | 
            -
                MD
         | 
| 99 | 
            -
              end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
              def test_plaintext
         | 
| 102 | 
            -
                assert_equal(<<~HTML, CommonMarker.render_doc(<<~MD, :DEFAULT, %i[table strikethrough]).to_plaintext)
         | 
| 103 | 
            -
                  Hello ~there~.
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                  | a |
         | 
| 106 | 
            -
                  | --- |
         | 
| 107 | 
            -
                  | b |
         | 
| 108 | 
            -
                HTML
         | 
| 109 | 
            -
                  Hello ~~there~~.
         | 
| 110 | 
            -
             | 
| 111 | 
            -
                  | a |
         | 
| 112 | 
            -
                  | - |
         | 
| 113 | 
            -
                  | b |
         | 
| 114 | 
            -
                MD
         | 
| 115 | 
            -
              end
         | 
| 116 | 
            -
            end
         | 
    
        data/test/test_footnotes.rb
    DELETED
    
    | @@ -1,48 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'test_helper'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class TestFootnotes < Minitest::Test
         | 
| 6 | 
            -
              def setup
         | 
| 7 | 
            -
                @doc = CommonMarker.render_doc("Hello[^hi].\n\n[^hi]: Hey!\n", :FOOTNOTES)
         | 
| 8 | 
            -
                @expected = <<~HTML
         | 
| 9 | 
            -
                  <p>Hello<sup class="footnote-ref"><a href="#fn1" id="fnref1">1</a></sup>.</p>
         | 
| 10 | 
            -
                  <section class="footnotes">
         | 
| 11 | 
            -
                  <ol>
         | 
| 12 | 
            -
                  <li id="fn1">
         | 
| 13 | 
            -
                  <p>Hey! <a href="#fnref1" class="footnote-backref">↩</a></p>
         | 
| 14 | 
            -
                  </li>
         | 
| 15 | 
            -
                  </ol>
         | 
| 16 | 
            -
                  </section>
         | 
| 17 | 
            -
                HTML
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              def test_to_html
         | 
| 21 | 
            -
                assert_equal @expected, @doc.to_html
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              def test_html_renderer
         | 
| 25 | 
            -
                assert_equal @expected, CommonMarker::HtmlRenderer.new.render(@doc)
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              def test_render_html
         | 
| 29 | 
            -
                md = <<~MARKDOWN
         | 
| 30 | 
            -
                  # footnotes
         | 
| 31 | 
            -
                  Let's render some footnotes[^1]
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  [^1]: This is a footnote
         | 
| 34 | 
            -
                MARKDOWN
         | 
| 35 | 
            -
                expected = <<~HTML
         | 
| 36 | 
            -
                  <h1>footnotes</h1>
         | 
| 37 | 
            -
                  <p>Let's render some footnotes<sup class="footnote-ref"><a href="#fn1" id="fnref1">1</a></sup></p>
         | 
| 38 | 
            -
                  <section class="footnotes">
         | 
| 39 | 
            -
                  <ol>
         | 
| 40 | 
            -
                  <li id="fn1">
         | 
| 41 | 
            -
                  <p>This is a footnote <a href="#fnref1" class="footnote-backref">↩</a></p>
         | 
| 42 | 
            -
                  </li>
         | 
| 43 | 
            -
                  </ol>
         | 
| 44 | 
            -
                  </section>
         | 
| 45 | 
            -
                HTML
         | 
| 46 | 
            -
                assert_equal expected, CommonMarker.render_html(md, :FOOTNOTES)
         | 
| 47 | 
            -
              end
         | 
| 48 | 
            -
            end
         |