The Preprocessor
Sveltemd works by leveraging the parse function exported by svelte/compiler
. It follows these steps:
- run a "preprocess" phase that escapes any characters that break svelte syntax. This mainly involves escaping
<
and{
characters, which svelte identifies as html and logic blocks. - call the
parse
function from svelte - this generates a Svelte Abstract Syntax Tree (Svast), basically a json representation of your svelte code. - Go to every text node in the svelte AST, and parse it as markdown.
- Congrats, your svelte has markdown now! 😊
Todo