4

When creating a code block in markdown with trailing line feeds, it displays correctly in edit mode, but after saving the edit I can briefly see it the same way, then the last line disappears.

Example:

This Python quine has a trailing new line. In edit mode, it displays, but not after that on https://codegolf.stackexchange.com/. It displays fine here, for some reason. Also, I'm fairly certain it used to work, as I've used blocks like these several times, but I just saw this bug today.

Markdown:

<pre><code>_='_=%r;print _%%_\n';print _%_

</code></pre>

Displayed:

_='_=%r;print _%%_\n';print _%_

See bug in action

In case the post linked above is changed later, I took some screenshots:

enter image description here

After saving edit:

enter image description here

Notes:

  • I tested this with Firefox, Chrome, Opera, and IE 11.
  • This bug doesn't occur in Firefox, but occurs in the others.
  • The "flicker" from correct to wrong only happens in Chrome and Opera.
  • Looks like it's the highlighting that strips the trailing new line (or not actually stripping it, but the <span> the highlighting inserts collapses it unless it's followed by another—no idea why though). The edit page doesn't have highlighting, so no issue there. – Cai Nov 10 '16 at 21:50

You must log in to answer this question.

Browse other questions tagged .