nwellnhof / perl-commonmark

Perl bindings for the CommonMark C library
https://metacpan.org/release/CommonMark
Other
5 stars 7 forks source link

Expected code block content ignores language type #1

Closed nanis closed 8 years ago

nanis commented 8 years ago

I tried to install CommonMark-0.230002 from CPAN using cmark 4e9abf79. nmake test failed with:

not ok 2 - create_* helpers

#   Failed test 'create_* helpers'
#   at t/08_create_helpers.t line 104.
#          got: '<h2>Header</h2>
# <blockquote>
# <p>Block quote</p>
# </blockquote>
# <ol start="2">
# <li>Item 1</li>
# <li>Item 2</li>
# </ol>
# <pre><code class="language-perl">Code block</code></pre>
# <div>html</html>
# <hr />
# <p><em>emph</em>
# <a href="/url" title="link title"><strong>link text</strong></a><br />
# <img src="/facepalm.jpg" alt="alt text" title="image title" /></p>
# '
#     expected: '<h2>Header</h2>
# <blockquote>
# <p>Block quote</p>
# </blockquote>
# <ol start="2">
# <li>Item 1</li>
# <li>Item 2</li>
# </ol>
# <pre><code>Code block</code></pre>
# <div>html</html>
# <hr />
# <p><em>emph</em>
# <a href="/url" title="link title"><strong>link text</strong></aTH><br />
# <img src="/facepalm.jpg" alt="alt text" title="image title" /></p>
# '
# Looks like you failed 1 test of 2.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests

Test Summary Report
-------------------
t/08_create_helpers.t (Wstat: 256 Tests: 2 Failed: 1)
  Failed test:  2
  Non-zero exit status: 1

Clearly, the expected HTML does not include the class="language-perl" attribute which is set in the test code on line 50:

    CommonMark->create_code_block(
        fence_info => 'perl',
        literal    => 'Code block',
    ),
nwellnhof commented 8 years ago

Your patch is correct, but it breaks with older versions of libcmark. I think it's related to this commit: https://github.com/jgm/cmark/commit/e384149e683fd6ea950ba9318525563175ca9f47

Let me think about a way to fix the test for both old and new versions.

nwellnhof commented 8 years ago

Fixed in master: https://github.com/nwellnhof/perl-commonmark/commit/1ef3c45afe10052ec0055620ecce8af56c1693a2

nanis commented 8 years ago

Nicely done.

nwellnhof commented 8 years ago

FWIW, I just released version 0.240100 containing the fix. (Might take some time until CPAN picks it up.)