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


(Bertrand Bellenot) #1

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.


(Bhanu Sharma) #2

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

(Bertrand Bellenot) #3

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


(Sam Saffron) #4

see:


(Bertrand Bellenot) #5

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

single line examples code not having newline

?


(Sam Saffron) #6

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.


(Bertrand Bellenot) #7

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


(Sam Saffron) #8

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]

(Bertrand Bellenot) #9

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…


(Sam Saffron) #10

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.


(Bertrand Bellenot) #11

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


(Sam Saffron) #12

Single line should work fine!

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

It only gets complicated when you start mixing.


(Bertrand Bellenot) #13

Is this example considered as

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

(Sam Saffron) #14

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


(Bertrand Bellenot) #15

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


(Sam Saffron) #16

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


(Sam Saffron) #21

This is fixed now per:


(Bertrand Bellenot) #22

Cool! Thank you very much!


(Régis Hanol) #23