Plain-text table detection should respect code fences

When pasting text inside a code fence block, the rich-to-markdown support is disabled.

“plain text table” detection should be disabled as well.

5 Likes

Will have a look :slight_smile:

6 Likes

Hmm, maybe I am a bit stuck here…

d-editor has an action called paste, in which it detects if you can paste HTML:

canPasteHtml = !isInside(pre, /(^|\n)```/g);

This returns false if you are currently inside of a code fence block. The conversion of the text into markdown happens in this function:

if (canPasteHtml && ...) {
      let markdown = toMarkdown(html);
}

So, conversion to markdown only happens when not inside of a code fence block. From what I understand, the “plain text table” detection is part of the markdown-it and hence should also be disabled here, because it’s not trying to convert the pasted text.

Am I missing out on something here?

2 Likes

Currently plain text table detection is not part of the “HTML pasting” feature. It is happening here. I think you have to move it to the end of this if condition.

6 Likes

Ouh, yeah, I see it. Thanks a lot!

EDIT: Opened a PR

https://github.com/discourse/discourse/pull/7436

9 Likes

https://github.com/discourse/discourse/commit/dc2ee78f7a667cd0ded8e198282def7ea51797bb

It’s done as per the above commit. Thanks for the PR! :heart: @venarius.

8 Likes

This topic was automatically closed after 2 hours. New replies are no longer allowed.