Ampersand (&) doesn't 'display' right if from linked post

AI-generated summary

In a bug report titled “Ampersand (&) doesn’t ‘display’ right if from linked post” (Discourse v1.3.0.beta4), user streger noted that ampersands in posts displayed as links are incorrectly converted to & in the target topic 1. User purezen_ volunteered to investigate, confirming the issue reproduces where amp; is appended to the first occurrence of & in linked posts 2. To assist with the fix, elberet suggested checking specific JavaScript files: better_markdown.js, markdown.js, and dialect.js, explaining that Discourse uses a server-side JS engine for text processing 3. After expressing gratitude for the community interest 7, sam confirmed they could no longer reproduce the issue and closed the topic 9.

This is really a small bother, just one of those perfection things I guess :blush:

So, if you make a post in some topic with ampersand (& char), like for example write: drag&drop; it will not display correctly if you use that post in some other topic as linked. It is displayed as html character, ‘&amp’

Discourse version: v1.3.0.beta4 +59
Viewing in latest Chrome 41.

p.s. I would show you the pictures for example, but restrictions doesn’t allow.

3 Mi Piace

Hi guys,

I am keen to contribute to Discourse and would like to work on this bug.
I have tried to reproduce the issue and it looks like Discourse appends amp; to the first occurrence of & where a linked post is displayed.
Would be glad if someone could suggest where to look for solving the same.

Cheers!

1 Mi Piace

Have a look at these files:

vendor/assets/javascripts/better_markdown.js
app/assets/javascripts/discourse/lib/markdown.js
app/assets/javascripts/discourse/dialects/dialect.js

Yes, those are JavaScripts; Discourse embeds a JavaScript engine (see lib/pretty_text.rb) server-side to cook submitted posts instead of duplicating the code in Ruby or trusting the client to submit valid cooked HTML. :slight_smile:

1 Mi Piace

Just to pop-up and thank you all for any reaction.
Glad to see that this community has people interested in this open source forum.
:heart: ya all

1 Mi Piace

I am no longer able to repro this, closing

1 Mi Piace