Markdown / bbcode code/quote bug

AI-generated summary

A bug was reported where using BBCode [code] blocks inside blockquotes renders incorrectly, showing the raw [code] tags instead of properly formatted code. RGJ first described the issue, noting that quoting code blocks via the blockquote button produces malformed output. supermathie clarified the expected behavior — code should render as fenced code blocks (```) inside quotes. zogstrip initially misunderstood but later confirmed the bug stems from how Discourse parses BBCode blocks, particularly in nested contexts like blockquotes zogstrip. RGJ acknowledged it’s likely a BBCode-specific issue and noted that using Markdown fenced code blocks (```) instead of [code] works around the problem. The issue is slated to be fixed by this PR zogstrip.

I’ve encountered an odd markdown markdown/bbcode bug.

Have a few lines of code in bbcode/markdown

[code]
line1
line2
[/code]

looks like

line1
line2

Quote them:

> [code]
> line1
> line2
> [/code]

looks like

line1
line2
4 Likes

… and should look like:

line1
line2

escaped:

> ```
> line1
> line2
> ```
2 Likes

Can you tell me what browser / OS you’re using and how you’re quoting these lines?

Here’s how it looks on my end

which gives the correct markdown

[quote="Richard - Communiteq, post:1, topic:299047, username:RGJ"]
```
line1
line2
```
[/quote]

which renders as

Oh wait, I think I understand what you mean :man_facepalming:

  1. Write down the following markdown
[code]
line1
line2
[/code]
  1. Select the text and click the “Blockquote” button so it prepends a > on each line
> [code]
> line1
> line2
> [/code]

Which renders (wrongly) as

line1
line2

Instead of

line1
line2

This is most likely an issue with the way we parse BBCode Blocks :thinking:

1 Like

Yeah, I already figured it was not a markdown issue per se but probably a bbcode issue.

The problem can be circumvented by using ``` instead of [code], as supermathie implicitly said in the second post.

1 Like

Will be fixed by

https://github.com/discourse/discourse/pull/26182

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.