6

While answering Is there something wrong with common mark?, I seem to have discovered a bug in the rendering of markdown.

**b.**​a should render as shown in this image:

b dot a with the b dot in bold

and indeed it does show that way in the preview area when the answer is being written. (And in the review window just before you post here on MetaSO.)

But once the answer is posted, it appears like this:

**b.**​a

Or if you're not seeing the problem, here's an image of it: not interpreted as markdown, still shows asterisks

3
  • 2
    This isn't the first inconsistency of that sort I've seen, for some reason the preview and actual output use different markdown renderers. I've never seen an explanation for why that is though. Feb 2 at 22:35
  • I just encountered a problem with the preview too. Tables in the preview look fine with text directly above, but when its posted it will break unless there is a space above it. Feb 3 at 3:56
  • I found the same thing with −_a_. Jun 21 at 6:12

1 Answer 1

5

It seems the actual unicode character gets ignored even with the front-end renderer, pasting directly the unicode character won't render the bold section: **b.**​a (Rendering: Screenshot of the front-end rendering showing the characters "**b.**a")

But it seems that any HTML entity will however always be seen as a delimiter, even if it's gonna be ignored when actually rendered as unicode, e.g **b.**Za (**b.**Za) vs **b.**Za (**b.**Za).
(Rendering: Screenshot of the front-end rendering showing only the first "b.Za" with the "b." part in bold).
So the front-end renderer might also need a little fix here where it should first interpret the HTML entities and then apply the markdown parsing rules.

As for the case of rendering that exact sequence in SO's posts, one solution to apply the bold section on seemingly only a part of a word is to use the HTML <wbr> element instead:
b.a (**b.**<wbr>a)
or even use the <b> HTML element directly since it's allowed by SO's markup:
b.a (<b>b.</b>a)

Investigating a bit more it seems that the U+200B character that OP used isn't supposed to be a delimiter anyway. So that would leave the HTML-entity -> saved as unicode round-trip as the only "bug", but even then I wonder if it's not a bug in commonmark.js itself that HTML entities are seen as delimiters... The specs say that "Conforming CommonMark parsers need not store information about whether a particular character was represented in the source using a Unicode character or an entity reference."

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .