tommoor / slate-md-serializer

A Markdown serializer for the Slate editor framework
MIT License
64 stars 36 forks source link

Escaping – inverted condition #34

Closed vaclavbohac closed 5 years ago

vaclavbohac commented 5 years ago

Hello,

first of all thank you for all the great work.

I've been working with slate-md-serializer last few days and I've came across something I find little strange. From my point of view markdown special characters should be escaped once used in the code block or code mark, yet the code here works exactly opposite.

https://github.com/tommoor/slate-md-serializer/blob/b58ccde277fd9bbf370ef7a3dec7de636a708aa7/src/renderer.js#L217

It resolves to true (meaning do escape) in case the leaf is not wrapped in code block and is not wrapped mark.

Am I right or am I missing something?

Thanks

tommoor commented 5 years ago

You're correct, but it's purposefully like that – the boundaries of the code block itself is enough information to not have to escape all of the characters within it. Whereas a * character appearing in a sentence for example needs to be explicitly escaped so that it isn't considered a markdown emphasis.