5

I came across this answer, which in my browser is rendered as:

Answer, code formatted as inline

I.e. code blocks are rendered as if they were enclosed in ``.

But if I try to edit it, what I see is:

Edit view, code formatted as expected

Code blocks are already enclosed in handlebars and the preview is rendered as expected.
I checked with both Chrome and Firefox, it doesn't look like a browser-related issue.
Since I cannot directly edit the post, I did not try to change something and save it (to check whether it is some kind of caching issue).

What is going on here?

  • This is by design as described by the accepted answer. – Brian Nickel Apr 4 at 19:53
13

Code blocks delimited with ``` ("fences") were implemented just this January (see this meta post). Before that, three backticks was equivalent to one backtick, resulting in inline code formatting, as your screenshot shows.

Even though the post had syntax that would be rendered differently now, that only happens when it's edited, this is also noted in the linked post:

As always when we make markdown changes, the question & answer view is not going to be impacted by this unless the post is edited,

So, it indeed was a kind of a caching issue. The appearance of the post was as it had been since the last edit, but the edit preview showed what it would be had the edit been saved. When Kusalananda actually edited it, the appearance was updated to match the current formatting rules.

  • Shame on me! I failed to realize it was a kind of edge case in which the answerer purposefully used code fences (supported elsewhere) when they were still unsupported on SE. And of course I should have imagined that the original markdown is not parsed each time we ask for a page. – fra-san Mar 30 at 8:44
  • Ah good. I did not have all the background to this. – Kusalananda Mar 30 at 8:46
4

I don't know what happened to that formatting. I tested the exact same markup in the sandbox and it rendered ok. I then added a single newline to the answer text and saved it, which seems to have fixed it.

I don't think it was the newline that I added that fixed it, but just the act of submitting it again.

If I remember correctly, that was the way that this sort of code block used to be rendered, up until recently (when code blocks were made ever so slightly "fatter"/more padded).

  • D'oh! Dumb question of mine, I realized what happened only after I read your answer. – fra-san Mar 30 at 8:45
2

As already noted, this is because the post was made before triple-backtick code blocks were supported, and hasn't been edited since support was added. A post's rendering is cached until the post is edited.

If you'd like to flex your edit muscles, this query looks for posts that look like they contain triple-backtick that isn't rendered properly. The query is far from perfect, it finds many posts where interpreting the triple-backticks as inline markup is fine, so please use your judgement and don't just blindly edit everything. As usual, if you go and edit posts that have a specific problem, please take the time to fix any other obvious problem such as other formatting issues, spelling, etc.

The database copy is updated only once a week, so posts that were fixed in the last few days will still show up.

  • Thank you for the query! I see, a fair amount of judgment has to be applied. I think I'll look at the most ugly-looking and at those that would be significantly scrambled by an update, trying not to annoy other users with excessive bumping. – fra-san Apr 5 at 17:31

You must log in to answer this question.

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