gruns
January 19, 2018, 12:24am
1
The emphasis delimiters *
and _
are parsed differently when proceeded by a hard linebreak. For example, compare the ASTs of
__strong__\
...
http://spec.commonmark.org/dingus/?text=__strong__\
next
and
**strong**\
...
http://spec.commonmark.org/dingus/?text=**strong**\
next
Only the latter, with the ending **
delimiter, is parsed as strong emphasis. The former is parsed into three text elements: [’__’, ‘strong’, ‘__’]. Why?
I can’t tell from the spec whether this – admittedly surprising – result is intentional or not.
Asterisks work inside words, underscores do not. A forced line break should clearly count as a word boundary and therefore this is a bug.
gruns
January 20, 2018, 9:56pm
3
@Crissov Is this a confirmed bug? I.e. shall I fix it?
Crissov
January 20, 2018, 10:43pm
4
All Commonmark implementations except commonmark.js
agree on this, see Babelmark .
Crissov
February 13, 2018, 4:29pm
5
Now filed as an issue at Github:
opened 04:27PM - 13 Feb 18 UTC
closed 08:34PM - 10 Jan 20 UTC
As mentioned twice on the Commonmark Discourse, in [2736](https://talk.commonmar… k.org/t/odd-behaviour-with-colon-emphasis-and-linebreak/2736) and [2695](https://talk.commonmark.org/t/emphasis-delimiter-parsing-difference-with-hard-linebreaks/2695), `commonmark.js` handles forced line breaks with backslash differently from ones with double space at the end of the line. This differs from all other reference implementations and therefore is a bug.
## Testcase 1
~~~~ markdown
_text_\
next line
*text*\
next line
~~~~
- Result: underscore emphasis is not recognized
- Expectation: same output for both paragraphs
[Dingus](http://spec.commonmark.org/dingus/?text=*foo*%5C%0Abar%0A%0A_foo_%5C%0Abar%0A%0A*foo*%20%20%0Abar%0A%0A_foo_%20%20%0Abar%0A)
[Babelmark 3](https://babelmark.github.io/?text=*foo*%5C%0Abar%0A%0A_foo_%5C%0Abar%0A%0A*foo*%20%20%0Abar%0A%0A_foo_%20%20%0Abar%0A)
## Testcase 2
~~~~ markdown
*text:*\
next line
*text:*
next line
~~~~
- Result: emphasis before backslash is not recognized
- Expectation: same output for both paragraphs
[Dingus](http://spec.commonmark.org/dingus/?text=*foo%3A*%5C%0Abar%0A%0A_foo%3A_%5C%0Abar%0A%0A*foo%3A*%20%20%0Abar%0A%0A_foo%3A_%20%20%0Abar%0A)
[Babelmark 3](https://babelmark.github.io/?text=*foo%3A*%5C%0Abar%0A%0A_foo%3A_%5C%0Abar%0A%0A*foo%3A*%20%20%0Abar%0A%0A_foo%3A_%20%20%0Abar%0A)
gruns
February 14, 2018, 8:10am
6
Great.
Thank you for creating a Github Issue, Christoph.