# Markdown / bbcode code/quote bug

**URL:** https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047
**Category:** Bug
**Created:** [March 12, 2024, 5:53pm UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047 "2024-03-12T17:53:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [March 12, 2024, 5:53pm UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047/1 "2024-03-12T17:53:03Z")

</div>

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

### Have a few lines of code in bbcode/markdown

```plaintext
[code]
line1
line2
[/code]

```

looks like

```plaintext
line1
line2
```

### Quote them:

```plaintext
> [code]
> line1
> line2
> [/code]

```

looks like

> ```plaintext
> line1
> line2
> ```

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [March 12, 2024, 7:39pm UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047/3 "2024-03-12T19:39:51Z")

</div>

… and _should_ look like:

> ```plaintext
> line1
> line2
> 
> ```

escaped:

````plaintext
> ```
> line1
> line2
> ```

````

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 14, 2024, 8:57am UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047/6 "2024-03-14T08:57:23Z")

</div>

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

> [@RGJ](#):
>
> ```plaintext
> line1
> line2
> 
> ```

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 14, 2024, 9:02am UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047/7 "2024-03-14T09:02:05Z")

</div>

Oh wait, I think I understand what you mean 🤦‍♂️

1. Write down the following markdown

```plaintext
[code]
line1
line2
[/code]

```

1. Select the text and click the “Blockquote” button so it prepends a `> ` on each line

```plaintext
> [code]
> line1
> line2
> [/code]

```

Which renders (wrongly) as

> ```plaintext
> line1
> line2
> ```

Instead of

> ```plaintext
> line1
> line2
> 
> ```

This is most likely an issue with the way we parse [BBCode Blocks](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse-markdown-it/src/features/bbcode-block.js) 🤔

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [March 14, 2024, 9:23am UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047/8 "2024-03-14T09:23:14Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 14, 2024, 6:21pm UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047/9 "2024-03-14T18:21:10Z")

</div>

Will be fixed by

[https://github.com/discourse/discourse/pull/26182](https://github.com/discourse/discourse/pull/26182)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 15, 2024, 6:21pm UTC](https://meta.discourse.org/t/markdown-bbcode-code-quote-bug/299047/11 "2024-03-15T18:21:47Z")

</div>

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