Disable automatic conversion of ASCII quotation marks to curly

Discourse automatically converts ASCII quotation marks (" ") to curlies (“ ”) when placed around text, except inside code blocks.

For example, here I’m typing the same thing twice: “Hello world”, "Hello world". As you can see, outside the code block the quotation marks turned curly.

Since newcomers often fail at properly putting their code inside code blocks, this “feature” makes it more difficult than necessary to copy their code when trying to reproduce a problem.

If possible, this conversion should be disabled.

Curly quotes are the least of your problems; all indentation is stripped :slight_smile:

Ideally, users would use code blocks correctly (as is suggested when they try to post), but if you want to try to help someone who didn’t, you can get the raw text of their post by replacing /t/whatever-the-topic-slug-is/ portion of the URL with /raw/: see your post at https://discuss.python.org/raw/20904.

Personally, I wish that view was made more easily findable; as far as I know, there’s no way to reach it via the UI, but instead manual URL manipulation is required.


Given that unformatted code would still unusable (indentation, etc), I don’t see what benefit removing the nice formatting from non-code test offers. Personally I just refuse to spend effort on questions until/unless code gets formatted.

Supposedly there was a plugin installed that would try to detect unformatted code, and pop up a modal dialog to prompt the user to correct it, but if so, it does not seem to be very successful. Does Discourse have a an mandatory onboarding flow that could be enabled? e.g. show new users how to make a formatted code block, and make them literally type one in correctly in some dialog before they are allowed to post for the first time?


The lost indentation is a bigger problem, but also harder to do anything about. The quotation marks are a hurdle, albeit minor, and if possible I don’t see the downside to removing it. IMO the typographic benefits of curly quotation marks over straight are minor at best.

That’s very useful, thanks!

This would perhaps be the ideal solution. Such a plugin doesn’t seem to exist, unfortunately.

See Unformatted Code Detector though.

Yes, but as Bryan noted, that has only been moderately successful. People are still posting unformatted code in the ‘Help’ section every day.

Oh, I’m sorry. I wasn’t paying enough attention and misread Bryan’s post.

Well, but is the plugin actually installed? Can you point me to where admins announced this? I wanted to see how it looked like, but trying the exact same example as on Unformatted Code Detector - theme-component - Discourse Meta in Unformatted Code Detector - #4 by jeanas, the post got sent without any warning…

Hmm, I could have sworn I’ve seen that warning myself previously, but indeed, no warning now. Strange.

This would perhaps be the ideal solution. Such a plugin doesn’t seem to exist, unfortunately.

I opened a discussion on Meta to solicit thoughts, so we will see :man_shrugging:


Well, it is enabled actually, Unformatted Code Detector - #8 by jeanas.

If it’s not working well, it means their heuristics have many false negatives (I suppose this is not easy to write heuristics for).

The Unformatted Code Detector plugin works but it does not detect short core :frowning: Few months ago someone also reported that it had not worked for them at all.

The proposed mandatory onboarding for code formatting would be great!

Meanwhile it could be helpful to create a post just about the code formatting in the welcome category and pin it there:

Then we can link it for newcomers when needed instead of writing the same instructions again and again.

I have added a section to the already pinned Quick Start message:

…but I think the section gets lost in the relatively long message and when I link the section of the message it shows the beginning of the message in the preview, not the linked section. You can see the useless preview above.

1 Like

I see that Meta immediately derailed the conversation into the code detector plugin, which is not relevant to your question and does not work at all for people attaching screenshots.

This is another example of that horrific techie practice of not listening to their users and thinking that they know better:

“Hi I am an experienced developer and run a Discourse instance and would like mandatory onboarding.”

“Oh no, you don’t want that, you want this plugin, even though it won’t solve your problem.”


Is it worth trying to get that thread restarted, or create a new one?

Pinning that to the Welcome To Discourse topic doesn’t help, because newbies don’t look at it. They go straight to the Help section and post screenshots of their code.

@steven.daprano Id make a new one, referencing the old one, and emphasize that the discussion that developed there about the plugin does not help at all with the case of new users posting images of code (and also the plugin still does not really seem to work in any case)

To be fair, the first response didn’t say “You don’t want that”. It
may be that there’s no mandatory onboarding available, but the first
response at lead suggested a plugin which has some benefit for the
underlying problem which motivated the query about mandatory onboarding.

Given how often we ask people for the underlying problem they’re
trying to solve (as opposed to the specific kind of perhaps-weird
technical thing a user’s trying to make work), this isn’t unhelpful.

Maybe it would have been nice if the response had said “Discourse
doesn’t have a mandatory onboarding feature” or “I don’t know if that’s
possible, but this other thing in this problem domain exists”. But they
didn’t say “no you don’t want that”.

Cameron Simpson cs@cskk.id.au

1 Like

Technically … yes this can be disabled by Discourse admins, we have the setting enable markdown typographer which amends a bunch of stuff in cooked:

Use typography rules to improve readability of text: replace straight quotes ' with curly quotes ’, (c) (tm) with symbols, -- with emdash –, etc

Glad to hear that the unformatted code detector is helping out.

I think there is some opportunity here for some GPT-4 integration to do some smart things here and catch even more of these. The unfortunate thing though is that the APIs are really slow at the moment so this would have to come after the fact.

We have enough problems with Python scoping/control info (and some
punctuation) being lost with code posted in “prose” mode. Do we really
want an LLM misparsing on top of that? It just feels like a recipe for
taking a poster’s known-to-have-a-problem code and further
mistranscribing it.

Unless you’re using GPT-4 as some kind of “oh this bit is probably code,
not prose” thing, I’d rather rely on some kind of regexpy based
heuristic. At least you’d know the basis for the inferences.