Linebreaks disappear in code blocks in old posts

Started by Snarky, Sat 08/10/2022 08:49:08

Previous topic - Next topic

Snarky

I happened to come across an old post of mine, and noticed that the code samples are mangled, with everything appearing on a single line. By trying to edit the post I see that there are linebreaks in the text, but for some reason they are ignored when the post is parsed and displayed.

Snarky

Here's another example, where one of the code blocks shows up fine and the other has the disappearing line breaks. (It also features some mangled Unicode characters.)

AGA

In your first example both code blocks show fine for me.  In the second one, it seems to work fine if it isn't wrapped in a hide tag.  I'd assume the code formatting plugin's parser doesn't recognise code blocks when they're nested inside another tag.

Snarky

Quote from: AGA on Sun 09/10/2022 10:17:16In your first example both code blocks show fine for me.

To be clear, they all show up as code-formatted, but for me the formatting inside the code block fails to recognize any of the line-breaks, rendering each one as one long line (most of which it thinks is commented out).

I see now that as you say, it applies specifically to code blocks wrapped inside spoiler tags. (But perhaps other tags as well?)

AGA

Yeah, when I said "show fine", I meant it rendered as you'd probably expect, linebreaks and all.  Only the hide example didn't.  All tags are handled programmatically, so I'd expect any nested tag will break:

Quote
Code: java
System.out.print("Hello");
System.out.println("World");

EDIT: or not...  Perhaps it's just the code tag library JS specifically then!

SMF spam blocked by CleanTalk