CR's added between list entries when pasting Markdown

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?

1 Like

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.

1 Like

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

3 Likes