# Language identifier is missing from fenced code block when it is quoted

**URL:** https://meta.discourse.org/t/language-identifier-is-missing-from-fenced-code-block-when-it-is-quoted/327895
**Category:** Feature
**Created:** [September 24, 2024, 10:53am UTC](https://meta.discourse.org/t/language-identifier-is-missing-from-fenced-code-block-when-it-is-quoted/327895 "2024-09-24T10:53:06Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew15-5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew15-5/32/451429_2.png) [@Andrew15-5](https://meta.discourse.org/u/Andrew15-5)
#### Post date: [September 24, 2024, 10:53am UTC](https://meta.discourse.org/t/language-identifier-is-missing-from-fenced-code-block-when-it-is-quoted/327895/1 "2024-09-24T10:53:06Z")

</div>

Someone can write something like this:

````plaintext
```py
print()
```

````

But when you then quote its output:

```py
print()

```

it will be quoted without the language identifier, like this:

> ```plaintext
> print()
> 
> ```

Specifically, I noticed this in [https://forum.typst.app](https://forum.typst.app), and not only me. This is quite annoying to fix manually every time, so I’m pretty confident that this is a bug. Preserving the language identifier is the expected behavior.

---

<div class="post-metadata">

### Author: ![Andrew15-5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew15-5/32/451429_2.png) [@Andrew15-5](https://meta.discourse.org/u/Andrew15-5)
#### Post date: [September 24, 2024, 10:55am UTC](https://meta.discourse.org/t/language-identifier-is-missing-from-fenced-code-block-when-it-is-quoted/327895/2 "2024-09-24T10:55:55Z")

</div>

> [@Andrew15-5](#):
>
> But when you then quote its output:
> 
> ```plaintext
> print()
> 
> ```
> 
> it will be quoted without the language identifier, like this:

Here is a live example of how the code block is quoted (without language identifier).

---

<div class="post-metadata">

### Author: ![Andrew15-5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew15-5/32/451429_2.png) [@Andrew15-5](https://meta.discourse.org/u/Andrew15-5)
#### Post date: [June 17, 2025, 1:34pm UTC](https://meta.discourse.org/t/language-identifier-is-missing-from-fenced-code-block-when-it-is-quoted/327895/3 "2025-06-17T13:34:37Z")

</div>

Today I found out that you can actually get the [info string](https://spec.commonmark.org/0.31.2/#info-string) by checking the HTML:

```html
<code class="lang-py hljs language-python" data-highlighted="yes">
  <span class="hljs-built_in">print</span>
  ()
</code>

```

If the language is known(?), it looks like it will show full name in `language-x`, but your specified in `lang-x`. However, even though `Python` is identified (visually), both classes will include `Python`.

This will help know which info string is used by someone else, or any post that you can’t edit (or can).

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [June 17, 2025, 2:00pm UTC](https://meta.discourse.org/t/language-identifier-is-missing-from-fenced-code-block-when-it-is-quoted/327895/4 "2025-06-17T14:00:53Z")

</div>

> [@Andrew15-5](#):
>
> But when you then quote its output:

You mean when you quote with text selection right? Using the full quote button work just fine.

> [@Andrew15-5](#):
>
> ```py
> print()
> 
> ```

That is the expected behavior, as when you select text we don’t have access to the original markdown and do an approximation.

Same as reported in

> [@Select to quote shouldn't strip \< and \> characters around links](https://meta.discourse.org/t/select-to-quote-shouldnt-strip-and-characters-around-links/358145/2):
>
> This only happens with the “select to quote” feature, and not with full quotes, because when doing a full quote we fetch the original markdown so we can give 100% accuracy. Select to quote feature must do HTML → Markdown conversion, so there will always be missing content from the original, specially when it is invisible from an HTML point of view.

---

<div class="post-metadata">

### Author: ![Andrew15-5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andrew15-5/32/451429_2.png) [@Andrew15-5](https://meta.discourse.org/u/Andrew15-5)
#### Post date: [June 17, 2025, 2:21pm UTC](https://meta.discourse.org/t/language-identifier-is-missing-from-fenced-code-block-when-it-is-quoted/327895/5 "2025-06-17T14:21:01Z")

</div>

> [@Falco](#):
>
> You mean when you quote with text selection right?

Yes.

> [@Falco](#):
>
> Using the full quote button work just fine.

There is no “Full quote” button.

> [@Falco](#):
>
> That is the expected behavior, as when you select text we don’t have access to the original markdown and do an approximation.

Can you not get the exact place in DOM where the selection is happening? Then it should be pretty easy to replicate whatever is needed.
