lostenderman / markdown

:notebook_with_decorative_cover: A package for converting and rendering markdown documents in TeX
http://ctan.org/pkg/markdown
LaTeX Project Public License v1.3c
1 stars 0 forks source link

When delimiters do not match evenly, Rule 12 determines that the excess literal _ characters will appear outside of the emphasis, rather than inside it #29

Closed lostenderman closed 1 year ago

lostenderman commented 1 year ago

See https://spec.commonmark.org/0.30/#example-456 and https://spec.commonmark.org/0.30/#example-458

Witiko commented 1 year ago

The corresponding unit tests are:

The issue seems related to the PEG patterns for parsing emphasis and strong emphasis, which use the rules for Gruber's Markdown rather than CommonMark.

testfiles/CommonMark_0.30/emphasis_and_strong_emphasis/107.test

%   ---RESULT--- "example": 456,
%   
%   <p>___<em>foo</em></p>
%   
%   ---\RESULT---

<<<
____foo_
>>>
documentBegin
underscore
underscore
underscore
emphasis: foo
documentEnd

Here is the result of running git checkout commonmark; cd tests; ./test.sh "testfiles/CommonMark_0.30/emphasis_and_strong_emphasis/107.test":

Testfile testfiles/CommonMark_0.30/emphasis_and_strong_emphasis/107.test
  Format templates/plain/
    Template templates/plain/input.tex.m4
      Command luatex                                   --interaction=nonstopmode  test.tex
*** test-expected.log   2023-01-01 01:05:24.165965730 +0100
--- test-actual.log 2023-01-01 01:05:31.075908498 +0100
***************
*** 2,6 ****
  underscore
  underscore
  underscore
! emphasis: foo
  documentEnd
--- 2,7 ----
  underscore
  underscore
  underscore
! underscore
! underscore
  documentEnd

testfiles/CommonMark_0.30/emphasis_and_strong_emphasis/109.test

%   ---RESULT--- "example": 458,
%   
%   <p><em>foo</em>___</p>
%   
%   ---\RESULT---

<<<
_foo____
>>>
documentBegin
emphasis: foo
underscore
underscore
underscore
documentEnd

Here is the result of running git checkout commonmark; cd tests; ./test.sh "testfiles/CommonMark_0.30/emphasis_and_strong_emphasis/109.test":

Testfile testfiles/CommonMark_0.30/emphasis_and_strong_emphasis/109.test
  Format templates/plain/
    Template templates/plain/input.tex.m4
      Command luatex                                   --interaction=nonstopmode  test.tex
*** test-expected.log   2023-01-01 01:06:23.795471954 +0100
--- test-actual.log 2023-01-01 01:06:29.675423277 +0100
***************
*** 1,6 ****
  documentBegin
  emphasis: foo
! underscore
! underscore
! underscore
  documentEnd
--- 1,4 ----
  documentBegin
  emphasis: foo
! emphasis: (underscore)
  documentEnd