Smart quotes breaking Quote template

AI-generated summary

The discussion revolves around a bug where smart quotes break the appearance of posts when quoting text in Discourse. jtbayly reports that selecting text and using the “Quote” function sometimes inserts a smart quote (curly quote) in the BBCode block, causing display issues. This occurs intermittently in Safari 18.4 and 15.3 on macOS, affecting sites running Discourse 3.4.2 and 3.4.0.beta3-dev. per1234 suggests disabling the “Markdown typographer” feature or removing double quotes from its settings as a workaround. sam notes that Discourse already has code to handle such edge cases but questions whether the issue is related to the new composer, which is not enabled on the affected sites. jtbayly confirms that disabling smart quotes in Safari’s settings resolves the issue but is not ideal. renato explains the root cause: inconsistent quotation marks in the BBCode block, noting that both quotes are converted if typed manually, but only the closing quote is affected during quoting. jtbayly observes the inconsistency and wonders if matching different quote styles like " and ” could be a simple fix. sam suggests updating the parser to handle such quote pairs and other odd quoting styles.

On at least two different Discourse sites I’ve run into a problem where when I select text and hit “Quote” to reply, smart quotes get used in one place which breaks the appearance of my post. Here is a screenshot of an example post that is displaying incorrectly because of the smart quote at the end of the first line (inside the brackets):

This has been happening for months, and I only just figured out what was going on with those posts.

I can reproduce it about 50% of the time on Safari 18.4 on Mac OS 15.4 as well as an earlier version of Safari on Mac OS 15.3.

The site I run where I see it is running Discourse 3.4.2. Another site I just ran into it on is running 3.4.0.beta3-dev.

I believe I have also seen some other people running into this issue on my site, but I haven’t double checked that today.

1 Like

Obviously a true fix should be made for a bug, but in case it will be useful in the meantime I’ll mention that a workaround might be to remove double quotes from the Markdown typographer quotation marks site setting, or disable the Enable markdown typographer site setting.

I am assuming that it is this “Markdown typographer” feature that is causing the replacement of the correct straight double quote character in the BBCode tag with the incorrect “smart” or “curly quote” character.

Its a good hunch, but I remember a similar issue from years ago and recall we even carry some code in Discourse that converts “→ " to handle this edge case.

@jtbayly do these sites have the new composer enabled?

Neither has the new compose enabled.

Another user reports if I turn off Smart Quote substitutions in Safari’s Edit->Substitutions->Smart Quotes, that will fix it.

I don’t particularly want to do that though. lol. I like my smart quotes most of the time.

I think this is the issue, in addition to the fact we imitate user input on the textarea on this type of addition to avoid losing the undo history.

I believe it can be “solved” with a spellcheck="false" on the element, but it has an obvious downside.

What’s causing the issue is the inconsistent quotation, it would work if it had the same style of quotes on both ends – any of these sets can be used:

It’s weird that only the second quotation mark got converted when quoting though, both sides get converted if the same BBCode is typed manually.

3 Likes

The problem is also inconsistent. It doesn’t happen every time, although I haven’t figured out when it happens and when it doesn’t.

It’s funny that it works with so many different quote options, but this one doesn’t work. I wonder…

Would it actually be a simple fix and not cause problems to match inconsistent quotation mark styles? " and ” in particular?

should we amend our parser to allow for the pair " ” and various obscure weird quoting that finds itself into bbcode?

2 Likes