Closed 0E9B061F closed 2 years ago
This would also allow users to use different markdown parsers, at least in theory, supposing the tokens are in the same format, or can be coerced to be. Possibly even parsers for different markup languages (I'm contemplating creating a small language with peggy and rendering its tokens using svelte-markdown, if this feature is added).
This actually looks great! Allows for extra flexibility without compromising on bundle size (or the original API)!
Could you also update the types on types/index.d.ts
? It'd be perfect that way.
I gave it a shot but I'm not very familiar with typescript. You should double check that.
Added documentation of the feature to the readme, too.
No problem! Glad to help.
Adds support for passing an array of tokens as the
source
option. This allows the user to generate and transform tokens freely before rendering. It also obviates the need forwalkTokens
support (#39). Users needing this feature can lex the tokens themselves.Any array given as
source
is assumed to be an array of tokens. If the source is not an array it is assumed to be a string and is treated normally.A simple test is included.