Description
In spec-compliant CommonMark the sequence **Hello**
is a valid span of bold text, however **Hello **
(notice the trailing space) is not a valid span of bold text, it's two literal asterisks followed by some text and then two more literal asterisks.
This is expected, it's in the spec.
If you need a trailing space within a span of bold (or italic for that matter) you can escape it using an html-style escape sequence like **Hello **
.
The commonmarker
gem parses all three of these correctly.
However if you parse **Hello **
(or manually construct the equivalent AST) and then render it to_commonmark, this library will NOT render the correct markdown.
markdown = '**Hello **'
doc = Commonmarker.parse(markdown)
puts doc.to_commonmark # outputs the wrong thing: **Hello **
Parsing the output again back to an AST completely loses the bold text.
You can find a minimal repro here.