The discussion revolves around a bug with [code] blocks in Discourse, particularly when a single line of code is used without a newline. Bertrand_Bellenot reports that such code appears as a grey thick line, and a similar issue occurs with lines like -- ----------------------------------------------------------- inside code blocks. itsbhanusharma notes that a newline after the [code] block is required for proper rendering. sam explains that the issue stems from CommonMark’s handling of optional newlines and that mixing code with text (e.g., [code] embedded in regular text) causes rendering problems. Bertrand_Bellenot clarifies that the main concern is the single-line case, which is common in their imported content. sam suggests using the Data Explorer plugin to find and fix such issues with regex. sam confirms it’s a bug related to optional newline handling and sam states it has been fixed in Discourse. Bertrand_Bellenot thanks the community for the resolution.
Our forum has a lot of [code][/code] in its topics, imported from our old phpbb3 forum. One of our user reported a couple of bugs with [code][/code]. For example, this:
A single line of code without newline looks as a grey thick line:
[code]TString option = GetOption();[/code]
Gives:
A single line of code without newline looks as a grey thick line:
TString option = GetOption();
And in this other example, the -- ----------------------------------------------------------- line gives another issue:
[code]hatiden@ubuntu:~$ gedit ~/.bashrc
hatiden@ubuntu:~$ cd /home/hatiden/garfield/
It means you are going to need to apply some sort of processor on the old imported code if you want multiline bbcode to be converted from:
some text [code]
test
[/code] test
to:
some text
[code]
test
[/code]
test
It is quite a fiddly transform and I did not want it included in core.
If I were to attack this on an old imported corpus I would apply a transform to the postsraw column that inserts the missing newlines and then run a full rebake.
Oh, OK, I see. Well, I think our main issue now is the single line one (as in my first post)
I wasn’t even aware of the one you describe, so I suppose there should not be many…
If there are not many, I would recommend installing the Discourse Data Explorer. Then you can find them and fix by hand. You just need to figure out the magic regex.