Bug with [code]anything[/code] on a single line by itself

Hi,

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/


hatiden@ubuntu:~/garfield$ ls
[/code]

Cheers, Bertrand.

3 Likes

Discourse supports the BBcode but You need a line break after [code] block for it to work.
eg:

[code]
hatiden@ubuntu:~$ gedit ~/.bashrc

hatiden@ubuntu:~$ gedit ~/.bashrc
hatiden@ubuntu:~$ cd /home/hatiden/garfield/

hatiden@ubuntu:~/garfield$ ls

Well, not really, for example a line with embedded TString option = GetOption(); works just fine…

see:

2 Likes

Thanks!
Does that mean that our (old) imported code will stay unreadable with

single line examples code not having newline

?

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 posts raw column that inserts the missing newlines and then run a full rebake.

3 Likes

Thanks for the info, even if this is not exactly the issue we have… (multiline works quite well)

I have no idea what you’re talking about, but thanks anyway for the tips

Multiline works well as long it is not mixed!

This works:

[code]
test

test
[/code]

This does not:

a [code]
test

test
[/code]

This does not:

[code]
test

test
[/code]a

This does not:

[code]a
test

test
a[/code]
4 Likes

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…

2 Likes

If there are not many, I would recommend installing the Data Explorer Plugin. Then you can find them and fix by hand. You just need to figure out the magic regex.

1 Like

I will try (maybe), thanks. But the single line ones are many… would that tool be a solution?

Single line should work fine!

Single line should [code]work fine[/code]!

It only gets complicated when you start mixing.

1 Like

Is this example considered as

mixing?
Is this example considered as 
[code]mixing?[/code]

I would say this snippet not being handled correctly is a bug

Is this example considered as 
[code]mixing?[/code]

It happens due to complications with optional newline handling in CommonMark

4 Likes

OK, so this was my original question, thanks! :slight_smile:

Sure, be sure to edit the OP to talk about the specific example. I can have a look at it.

This is fixed now per:

https://github.com/discourse/discourse/commit/a0cd54750cca2866dfa978858c21c1a88a09899b

7 Likes

Cool! Thank you very much!