Open golmansax opened 6 years ago
Yea, the serializer is definitely over-safe when it comes to escaping right now. As the output is still valid Markdown and i've treated it as more important that the representation in Slate does not ever change between save and reload.
If you're able to make that test pass without failing the existing escaping tests then I'm very open to a PR. I do think the regex would have to get significantly more complex though?
@tommoor I took a look at the source code and I understand what you mean. Some ideas of how to address this:
#
if at beginning of line).I'm also going to pass on it for now and re-visit if it becomes a more pressing issue.
Add conditionals per punctuation mark (e.g. only escape # if at beginning of line).
If anyone wants to take on this improvement this seems like the way to go. The escaping will probably need splitting into multiple regex, one for each special character with it's own conditions.
@tommoor A possible bug with over-escaping is that some markdown parsers automatically transform link text into link tags. So on my project, https://google.com (when written as text) is turning into https://google\.com.
I'll try to solve this at some point but wanted to let you know first.
Hi, this issue is probably related to https://github.com/tommoor/slate-md-serializer/issues/9. I'm seeing extraneous backslashes on punctuation marks in text.
For example, I added this test:
Which resulted in:
If you agree with the test I wrote, I'm happy to take a stab at this with a pull request. Let me know.