PDA

View Full Version : Editor won't parse nested bbcode correctly



Geordnet
2013-09-25, 08:12 PM
Specifically, I'm trying to get something like this to work:

{SPOILER}{code}{SPOILER}
{b}Text here.{/b}
{/SPOILER}{/code}{/SPOILER}

Where the internal spoiler brackets weren't parsed.

But what I got was:


Text here.



So, I tried adding a noparse tag:
{SPOILER}{code}{noparse}{SPOILER}
{b}Text here.{/b}
{/SPOILER}{/noparse}{/code}{/SPOILER}

But that was even worse:


Text here.



I tried putting the outer spoilers on another line. However, this:
{SPOILER}
{code}{noparse}{SPOILER}
{b}Text here.{/b}
{/SPOILER}{/noparse}{/code}
{/SPOILER}

Results in this:



Text here.




Removing the inner spoiler tag helps, but...
{SPOILER}{code}{noparse}
{b}Text here.{/b}
{/noparse}{/code}{/SPOILER}

It alone wasn't enough.


Text here.


Edit: or maybe it was. Hmm, I could have sworn I tried that...

Only the following code would parse right:
{SPOILER}
{code}{noparse}
{b}Text here.{/b}
{/noparse}{/code}
{/SPOILER}

Producing:



Text here.




Which is bad, because all of these statements should have parsed correctly. Obviously something is flawed in the bbcode parser, and it needs to be fixed.

Rawhide
2013-09-25, 08:47 PM
Which is bad, because all of these statements should have parsed correctly. Obviously something is flawed in the bbcode parser, and it needs to be fixed.

Only the second one (and any variations that are the same but with different line breaks) should have parsed correctly and produced the result you wanted:
{SPOILER}{code}{noparse}{SPOILER}
{b}Text here.{/b}
{/SPOILER}{/noparse}{/code}{/SPOILER}

{code} does not do the same thing as {noparse}, and thus {noparse} needs to be used in conjunction with it in order to display bbcode in a code block.

Thus, the very first one you listed parsed correctly, with a spoiler inside the code block. Though, the CSS interaction between the two results in an interesting display style. Spoilers were not meant to be nested in code boxes.
{SPOILER}{code}{SPOILER}
{b}Text here.{/b}
{/SPOILER}{/code}{/SPOILER}

It would appear that {noparse} and {spoiler} aren't interacting correctly, but this isn't something we will be investigating at the moment. Instead you should use a workaround like this:


Text here.

Geordnet
2013-09-25, 09:05 PM
Only the second one (and any variations that are the same but with different line breaks) should have parsed correctly and produced the result you wanted:
{SPOILER}{code}{noparse}{SPOILER}
{b}Text here.{/b}
{/SPOILER}{/noparse}{/code}{/SPOILER}

{code} does not do the same thing as {noparse}, and thus {noparse} needs to be used in conjunction with it in order to display bbcode in a code block.

Thus, the very first one you listed parsed correctly, with a spoiler inside the code block. Though, the CSS interaction between the two results in an interesting display style. Spoilers were not meant to be nested in code boxes.
{SPOILER}{code}{SPOILER}
{b}Text here.{/b}
{/SPOILER}{/code}{/SPOILER}

It would appear that {noparse} and {spoiler} aren't interacting correctly, but this isn't something we will be investigating at the moment. Instead you should use a workaround like this:


Text here.

Huh, most other boards automatically ignore bbcode in {code} tags.

But breaking up the {spoiler} tags like that is clever; thanks.

Rawhide
2013-09-25, 09:26 PM
Huh, most other boards automatically ignore bbcode in {code} tags.

But breaking up the {spoiler} tags like that is clever; thanks.

I do know that some other board software does, but vBulletin does not.