pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.27k stars 96 forks source link

Escaping 'Curlywurlies' in text #19

Closed theSherwood closed 4 years ago

theSherwood commented 4 years ago

Using backticks to escape '{...}' changes the styling. Is there a way to use brackets in text so that they get the same styling as the rest of the paragraph?

pngwn commented 4 years ago

MDsveX doesn't escape curlywurlies intentionally so that end-users can use expressions in MDsveX just like they can in Svelte. Since this is a preprocessor (and now supports all Svelte template syntax) this isn't something I'm likely to change.

The solution is to do the same as you would in a Svelte component.

Using HTML entities:

{: { }: }

Or:

{ '{' + '}' }

In principle, I could add a flag to escape these characters but then I would need to do some more comprehensive parsing to escape certain curlywurlies and not others, which I don't think is worth the tradeoff as it is a seldom used character. The manual approach should be fine for those times when such a character is needed in your template.

theSherwood commented 4 years ago

Ahh. Okay. That makes sense. It makes the markdown a little bit less amenable to prose. But I understand the decision for consistency's sake.

Thanks for making MDsvex, by the way. It is great.

Edit: typo fix.