pngwn / MDsveX

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

Code block demo/sandbox functionality? #432

Open janosh opened 2 years ago

janosh commented 2 years ago

Is there a way to display a piece of code both as text and as the HTML it renders to next to each other without a custom preprocessor? Should look something like this but without needing to type and maintain the same code twice.

Screen Shot 2022-02-26 at 18 09 17

rmunn commented 2 years ago

This is a long-standing feature request; I believe https://github.com/pngwn/MDsveX/issues/52 was primarily motivated by this use case. I had a suggestion here, using the generic directives proposal from CommonMark. And pngwn is currently working on a new markdown parser implementation that will use what he's calling Penguin-flavored markdown; generic directives will be part of it.

So there's no way to do this now as far as I know, but it will be possible once mdsvex 1.0 is finished.

seblammers commented 1 year ago

I think this was kind of solved here:

https://github.com/mattjennings/mdsvexamples