ProseMirror / prosemirror-markdown

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

Does not escape # character if it's not followed by whitespace #52

Closed VV-EE closed 3 years ago

VV-EE commented 3 years ago

The issue was that the escape function escaped hashtags even when it wasn't followed by whitespace. In that case the # should not be escaped since for ex. #myhashtag is not a header ( there has to be a whitespace according to the markdown spec ). This caused an issue when doing markdown->prosemirror->markdown conversion #myhashtag became /#myhashtag, I think the conversion to and back should should not change anything.

Illustrations

Original markdown editor: original markdown After WYSIWYG conversion: to prosemirror Back to markdown: result markdown

marijnh commented 3 years ago

# can be safely escaped in Markdown, so I think the current behavior is acceptable. There's no guarantee that text round-trips through the conversion without changing—only its meaning shouldn't change, the actual characters will change. I can also imagine people defining custom syntax (such as hashtag syntax) that acts on unescaped # characters, so escaping them seems useful and I don't really want to further complicate that.

VV-EE commented 3 years ago

Sounds reasonable, thanks for the reply!

VV-EE commented 3 years ago

@heyakyra No, Marijn is right. One of my clients still needed this, it's hosted at https://github.com/VV-EE/prosemirror-markdown