ProseMirror / prosemirror-markdown

ProseMirror Markdown integration
https://prosemirror.net
MIT License
344 stars 81 forks source link

Markdown parser does not correctly handle marks around inline nodes #69

Closed jimmy-jaffin closed 2 years ago

jimmy-jaffin commented 2 years ago

I expanded the schema and markdown-it with a new type of node with markup that looks like this: $$[text]. This is an inline node and NOT a mark because these nodes need to be able to be placed next to each other (e.g. $$[textOne]$$[textTwo]).

If I then try to use a mark, such as strong, in a paragraph surrounding my new node, the parser stops the mark after my custom node.

For example, this markdown: **here is some text $$[exampleText] some more text**

Becomes incorrectly parsed and rendered into something like this: <strong>here is some text </strong><span class="myCustomClass"><strong>exampleText</strong></span> some more text

I am using parsemirror-markdown version 1.8.0 according to npm.

marijnh commented 2 years ago

Does the issue exist on the markdown-it or the prosemirror-markdown level? (I.e. what do the tokens markdown-it produces for this look like.)

jimmy-jaffin commented 2 years ago

Markdown-it seems to be producing the correct tokens, so I believe it's on the prosemirror-markdown level. On line 81 of from_markdown.ts I see this line inside closeNode which I believe is the culprit:

if (this.marks.length) this.marks = Mark.none

marijnh commented 2 years ago

Ah, right, I see what you mean now. Attached patch should help.