Backticks not transferred when quoting only the code span

AI-generated summary

A bug was reported by fhe where backticks denoting code spans (e.g., %APPDATA%\%TEST%\test.txt) are not preserved when quoting only the code span, causing misinterpretation of escaped characters. Initially, codinghorror couldn’t reproduce it, but fhe clarified that the issue occurs specifically when quoting only a portion of a code span — not the entire span — and noted it’s a recurring problem in their community, leading to confusion over missing backslashes. codinghorror acknowledged the scenario as niche and updated the topic title for clarity. Later, codinghorror confirmed the issue is resolved when quoting sufficiently large portions of text, crediting prior improvements by @vinothkannans that preserve formatting in quotes. The fix ensures backticks and code span integrity are maintained in quoted content, reducing user confusion. fhe emphasized that the bug also affects partial selections from code spans, not just full spans, highlighting its real-world impact on technical discussions.

I’ve noticed that backticks that denote code spans are not part of the quoted text when creating a quote. This is relevant where special characters are used that are treated differently depending whether they’re used inside a code span or not.

Example

The original text

%APPDATA%\%TEST%\test.txt

when quoted, becomes

treating the first backslash as an escape for the following percent sign and resulting in a misquote, where the correct quote would be

1 Like

No repro, I just quoted and it looks fine to me.

You need to quote the code span only for reproducing the issue.

That’s a very .. specific .. scenario. I edited your topic title to make it more clear.

It happens quite often in my community, resulting in follow-up posts where users state that the "" was somehow omitted (that’s actually "\") which then results in even more confusion.

And regarding the original topic title: it also happens when quoting from code spans, meaning that you don’t need to quote the complete code span. It happens also with parts of those.

As long as you quote enough, thanks to @vinothkannans prior efforts enhancing Discourse to copy essential formatting in quotes, this is now working. :raised_hands:

4 Likes