I have found a bug with the Markdown renderer which causes a difference between what the preview shows and how it is being rendered after posting. The issue appears when attempting to use a forced line break using a trailing backslash (\), if the backslash appears after an URL.

For example, this code produces the problem:

Foo http://example.com/test.\

In the preview, this is rendered correctly. There is a line break (<br>) after the first line and the “Bar” appears in the second line. However, after saving the post, the post renderer will include both the dot and the backslash in the hyperlink causing the link to be http://example.com/test.\ instead of just http://example.com/test. This appears to only happen when there is a path segment in the URL (i.e. not for http://example.com.\).

Here is a screenshot how the preview is rendered, using a quotation block for visualization (though the error is caused regardless of whether a quotation block is used or not):

Rendering in preview

And this is how it is then rendered after posting:

Incorrect rendering after posting

I’ve noticed this on Stack Overflow, but reproduced it in the Markdown sandbox here on meta. Rendered with the commonmark.js, it works correctly as you can see in this example.

You must log in to answer this question.

Browse other questions tagged .