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

When I type "[", a "\" appears before "[" in the markdown source code #1278

Closed
2 tasks done
bent2685 opened this issue Mar 23, 2024 · 10 comments
Closed
2 tasks done

When I type "[", a "\" appears before "[" in the markdown source code #1278

bent2685 opened this issue Mar 23, 2024 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@bent2685
Copy link

bent2685 commented Mar 23, 2024

Initial checklist

  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected packages and versions

7.3.3

Link to runnable example

No response

Steps to reproduce

当我输入[的时候,[的前面会出现一个多余的\

导致无法使用 Link和 Img,因为Link和Img是[开头。在官方的Playgroud中也出现了这个现象

eg:
当我输入

[百度](http://www.baidu.com/)

在md源码中会被解析成

\[百度]\(http\://www\.baidu.com/)

最终导致Link无法显示

Expected behavior

[百度](http://www.baidu.com/)

Actual behavior

\[百度]\(http\://www\.baidu.com/)

Runtime

Electron

OS

macOS

Build and bundle tools

Vite

@bent2685 bent2685 added the bug Something isn't working label Mar 23, 2024
@bent2685
Copy link
Author

image

@bsdayo
Copy link

bsdayo commented Apr 4, 2024

Meeting the same problem, cannot type any links.

image

@chainlist
Copy link

Same here.

@Saul-Mirone do you have a plan/idea how to fix this?

@ravi-ojha
Copy link

ravi-ojha commented May 6, 2024

image

Same issue (but trailing slash) with using Shift+Enter and then typing anything.

Edit: Found syntax-tree/mdast-util-to-markdown#45
It looks intentional for this trailing slash. Although, this is not standard markdown syntax.

@DanielPower
Copy link

DanielPower commented May 25, 2024

I'm seeing this as well. If I include a [ in the initial value, it is parsed correctly and links work. But if a [ is typed into the editor, it is escaped with \. This means links are impossible to create in the editor, including in the Playground.

@DanielPower
Copy link

I've tested that this issue was introduced in 7.3.3 and still exists in 7.3.6. Reverting to 7.3.2 resolves the problem.

@Saul-Mirone
Copy link
Member

I've tested that this issue was introduced in 7.3.3 and still exists in 7.3.6. Reverting to 7.3.2 resolves the problem.

That part was extracted as @milkdown/plugin-automd. You can install the plugin and enable it.

@DanielPower
Copy link

Is the escaping of square brackets intentional, or is it a bug that will be resolved at some point? I'm writing a plugin for wiki links, which uses square brackets. Is the expectation that I need to write an InputRule that removes escaped brackets?

Is plugin-automd now required for commonmark support? It doesn't appear to be documented, but links no longer work with the commonmark preset alone.

@Saul-Mirone
Copy link
Member

Is the escaping of square brackets intentional, or is it a bug that will be resolved at some point? I'm writing a plugin for wiki links, which uses square brackets. Is the expectation that I need to write an InputRule that removes escaped brackets?

Is plugin-automd now required for commonmark support? It doesn't appear to be documented, but links no longer work with the commonmark preset alone.

  1. The escaped brackets is introduced by remark, it will add escape mark to squre bracket to make sure the brackets won't be parsed as links.

  2. If you really want to inseart a link instead of bracket, there're a lot of methods to do that. For example, an inputrule should be created to convert patterns like [\w+](\w+) into links. You can also use a shortcut to add link to the selected text.

  3. For plugin-automd. It tries to reparse everything in user input and it will introduce other issues. So I split it out from preset-commonmark to let users to decide if they need to use it. I plan to add another inputrule for links but I just didn't get time to do that. I'm working on the @milkdown/components and @milkdown/crepe libraries.

@bent2685
Copy link
Author

@Saul-Mirone
Thank you! I took your advice and added @milkdown/plugin-automd, then enabled it, which fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants