Discourse Mangling Text in a Code Block

AI-generated summary

The discussion revolves around a bug in Discourse where backslashes in code blocks are incorrectly rendered, particularly affecting \1 in AppleScript code. ccstone reported the issue, noting that while <code> tags and <pre> tags work in some contexts, code blocks fail to preserve the correct formatting. codinghorror confirmed the bug and demonstrated it with examples. sam provided a minimal repro, showing the issue across various code block formats. cpradio explained that the issue is due to Discourse not yet using CommonMark, which is under review. sam later confirmed the fix has been implemented in the new engine, with the rendering now working correctly in all code block types, though the update is pending rollout.

Hey Folks,

I’m posting AppleScript on the Keyboard Maestro forum using a code-block.

A user reported a compile problem with my code.

Rendered by Discourse:

set foundList to cng("<td class=\"pricesens\">.+title=[[:punct:]](price sensitive)[[:punct:]]>", "\\1", foundList) of me

What should be:

Double-Quote-Backslash-Backslash-1-Double-Quote

Is rendering as:

Double-Quote-Backslash-BackTick-Double-Quote.

“\\1”

Using a <code></code> block on the forum I can get the few characters above to show up correctly by adding a backslash, but it the code-block doesn’t like my complete line of code.

Using <pre></pre> tags doesn’t help on the forum, although it works perfectly well in a normal html page.

Code-blocks should be completely unadulterated, so I conclude this is a bug.

–
Regards,
Christopher Stone

3개의 좋아요

Seems like a bug, yes:

Indented 4 spaces

set foundList to cng("<td class=\"pricesens\">.+title=[[:punct:]](price sensitive)[[:punct:]]>", "\\1", foundList) of me

As a code block

set foundList to cng("<td class=\"pricesens\">.+title=[[:punct:]](price sensitive)[[:punct:]]>", "\\1", foundList) of me

The two backslashes in front of the 1 are not rendering correctly. You could try it on Babelmark as well…

Minimal repro

\\1

\\1

\\1
\\1

Broken in all code version.

3개의 좋아요

Hey Folks,

This bug is still not fixed.

Code rendering needs to be bombproof reliable…

-Chris

They aren’t on commonmark yet, and this is tagged to be reviewed when they move to it.

4개의 좋아요

And … it now works!

\\1

\\1

\\1

Yay

```
\\1
```

`\\1`

    \\1

It will take a bit till this is rolled out but new engine fixes it:

3개의 좋아요