CR's added between list entries when pasting Markdown

AI-generated summary

Users are reporting that when pasting Markdown lists (bullet or numbered) or plain text into Discourse, extra carriage returns are automatically inserted between lines, causing unintended spacing. RangerRick first observed this behavior in both this Discourse instance and their own at https://opennms.discourse.group, noting it began a few months ago. The issue persists regardless of the “traditional markdown linebreaks” setting but is resolved by disabling “enable rich text paste” — suggesting the rich text paste handler is misinterpreting or converting clipboard content. maiki and sam suspect the problem may originate from the VSCode plugin “Markdown All In One,” which might be copying content as HTML rather than plain Markdown, causing Discourse to misconvert it. RangerRick confirms using VSCode on Mac with that plugin, though the copied content appears as plain text. maiki and Stephen suggest testing with other editors (e.g., TextMate) to isolate whether the issue is specific to VSCode or the plugin. The consensus leans toward a clipboard/HTML conversion bug in the VSCode plugin, though further debugging of the clipboard’s HTML content is needed to confirm.

Sometime in the last couple of months, Discourse has started adding carriage returns between bullet list entries when I paste markdown into a new post window.

For example, when I copy a simple list from my text editor:

* foo
* bar
* baz

…and then paste it into a new topic, I get:

I have confirmed this happenswhen I paste into this discourse, even, right here, in this text input box, like so:

  • foo

  • bar

  • baz

Incidentally, when I pasted above into a ``` section I had already started at the top for the example text, it pasted properly (but of course didn’t get formatted into bullet points).

Oh, I just thought of something. Wonder if it does it for numbered lists too?

  1. foo

  2. bar

  3. baz

…yup.

And I just tried 3 lines of just text, and it appears to do the same, it’s adding carriage returns to everything:

foo
bar
baz

…becomes 3 separate “paragraphs”:

foo

bar

baz

EDIT:

(Emphasis added). Oops. I didn’t read carefully enough. You even included it in the title. Sorry.

original response

By “discourse” do you mean this site or some other site?

If you are the admin of a Discourse site you might be interested in this site setting:

traditional markdown linebreaks

Use traditional linebreaks in Markdown, which require two trailing spaces for a linebreak.

Well, it happens here and it happens on our instance: https://opennms.discourse.group

I’ve tried changing this setting and it seems to have no effect on pasting adding extra linebreaks to the resulting input.

I did find the “enable rich text paste” option while looking for that, and I can confirm that turning it off fixes things. So it appears that enabling that mangles markdown even though it should presumably only be doing HTML?

The first thing that popped in my head: are you sure it isn’t HTML? As in, when it’s copied to your buffer from wherever, is it still markdown, or did it convert markdown into HTML, and then is trying to reverse it back.

Just a random thought, probably a bug. But there are so many IDE and text editors that are essentially browser windows… :thinking:

It’s VSCode with the Markdown All In One plugin enabled (on Mac). It worked up until a few months ago, I presume something changed in the code or the discourse instance, but I couldn’t tell you when exactly. VSCode has certainly updated a billion times since then, too. As far as I can tell when I copy it, it’s just “regular” text. Not sure how to debug that though…

You can copy and paste markdown text from other editors and see if it produces the same results in Discourse. :sunglasses:

This feels like a support request to me.

My guess is that this Markdown All in One plugin is placing multiple things into the clipboard, we pick the HTML and then convert it to Markdown.

Not sure really how to resolve this, feel like a but in that VS Code plugin, will need to debug the HTML it is generating in the clipboard.

Do you get the same result pasting from something like Textmate?