I feel that Discourse's default quoting behavior is a bit inadequate for this forum; in particular, it tends to drop or garble quoted text (for background and previous discussion, see my response to @xwu's comment). For example, quoting text with links silently drops the link attribute, and code formatting disappears. More seriously, HTML entities appear in some cases. Here are some examples:
I agree this is a problem. It seems the site is trying to do quoting purely based on the rendered html of the comment, rather than its original markdown.
However, because a user can *edit* their own posts, we know the server at least stores the original markdown. So it is certainly *possible* to implement a quoting behavior wherein the server returns either the original markdown alone, or the html augmented with the markdown which generated each element.
My understanding is that the “difficult part” of quoting is to figure out exactly where the selected text begins and ends in the markdown, since the selection happens in rendered html. However if the html were augmented with the markdown on a per-tag basis, this would be much more easily solved.
Even aside from that, it should be fairly straightforward to traverse the html within the selection to bring in the matched tags, and if there are any unmatched tags then locate the matching ones outside the selection and bring them in as well. I’m not sure why this isn’t already being done.
The problem is that you’re allowed to quote only a certain part of a post by selecting it and embedding it which makes it difficult to reuse the saved Markdown source of the original post.
The solution could be this: when you select something and make a quote out of it, Discourse should take the HTML for what was selected, convert it to Markdown format, and then put that in the quote. The generated Markdown from the HTML can’t be exactly the same as the original one that created the HTML, but it’s irrelevant in this case because it will produce the same HTML result.
Reverse markdown filters are already a thing. So the hard part would be to traverse the HTML DOM, and from that generate HTML which will allow you to generate some plausible Markdown for those elements, which could then feed the editor in Discourse.