Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown parser combines two or more same autolink into a single anchor element #115

Open
vivinkrishna-ni opened this issue Dec 15, 2023 · 2 comments

Comments

@vivinkrishna-ni
Copy link

Issue

When two or more autolink markdowns are given as an input to the markdown parser without a space in between the autolinks render as a single anchor element.

Repro

Markdown string <link:1><link:1> given to the parser() method of markdown parser. Please note that the links within the <> are the same and no whitespace between them.

Reproducing the same in prosemirror markdown editor in the example given in https://prosemirror.net/examples/markdown/
prosemirror-same-link-issue

Current behavior

They are parsed as a single anchor element combined as below

<a href="link:1">link:1link:1</a>

However, if we give two different links without a space or the same link with a space, they are parsed as expected.

Expected behavior

They should be parsed as two separate links

<a href="link:1">link:1</a>
<a href="link:1">link:1</a>

Context

We use markdown parser and serializer to store the information for our rich text editor and we extend the prosemirror-markdown to leverage our needs. However, we enable only autolink feature from CommonMark flavor as part of our requirement.

@marijnh
Copy link
Member

marijnh commented Dec 15, 2023

The way ProseMirror marks work, there is no concept of individual links, just text styled with link marks. So this distinction cannot be represented in ProseMirror's document model, and what you are looking for here will not be supported by prosemirror-markdown.

@vivinkrishna-ni
Copy link
Author

Thanks @marijnh for your quick response. Since we use both parser and serializer for converting markdown to DOM and vice versa, the serializer changes the data that is given to the editor. For example, with the same markdown string <link:1><link:1>, serializer would return [link1link1](link1) as the parser changes the DOM. This alteration in the original user-input markdown string can result in data loss or modification.

Also, when we tried with the common mark example editor or in markdown-it demo editor, we observed that they converted the same input into two different anchor elements.
image

So, it would be really helpful if there is any configuration we can utilize either in the parser or in the serializer to preserve the original markdown string that has been given earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants