Tcl Library Source Code

View Ticket
Login
Ticket UUID: 0d824f26fb2a3c6c152c6fcf2da209ed9073dca
Title: Markdown mishandles escaped characters in some cases
Type: Bug Version:
Submitter: aku Created on: 2022-03-30 12:22:39
Subsystem: markdown Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2022-03-30 12:22:39
Resolution: None Closed By: nobody
    Closed on:
Description:
The following tests show when escaped characters are mishandled:

_____________________________________________

foreach {k input result notes} {
    5  {_____}    {x <strong>_</strong> x}	.AMBIGUOUS
    6  {__\___}   {x <strong>_</strong> x}	.
    7  {_\_\_\__} {x <em>___</em> x}		.
    8  {__.__}    {x <strong>.</strong> x}	.
    9  {__\.__}   {x <strong>.</strong> x}	.FAIL
    10 {__*__}    {x <strong>*</strong> x}	.
    11 {__\*__}   {x <strong>*</strong> x}	.FAIL
    12 {. \.}     {x . . x}			.
    13 {_ \_}     {x _ _ x}			.
    14 {[foo_bar](sna_fu)}   {x <a href="sna_fu">foo_bar</a> x}	.
    15 {[foo\_bar](sna_fu)}  {x <a href="sna_fu">foo_bar</a> x}	.
    16 {[foo_bar](sna\_fu)}  {x <a href="sna_fu">foo_bar</a> x}	.FAIL
    17 {[foo\_bar](sna\_fu)} {x <a href="sna_fu">foo_bar</a> x}	.FAIL
} {
    test basic-1.$k "escaped characters: ($input)" -body {
	convert "x $input x"
    } -result "\n    <p>${result}</p>\n"
}
_____________________________________________

1.5 is not a true failure. Just ambiguous in treatment. Actual result is neither 6 nor 7, but something else, an empty strong before an underscore, i.e. `{x <strong></strong>_ x}`. The Babelmark consensus on this is different again, `{x _____ x}`.

The .9 and .11 demonstrate that escaped characters inside of an emphasis are not handled correctly.
Ditto .16, .17 for escaped characters in the link target.

The Babelmark consensus converts them as I expected:

    https://johnmacfarlane.net/babelmark2/?text=x+__%5C.__+x
    https://johnmacfarlane.net/babelmark2/?text=x+%5Bfoo%5C_bar%5D(sna%5C_fu)+x