Skip to content

Conversation

@0E9B061F
Copy link
Contributor

@0E9B061F 0E9B061F commented Jul 20, 2022

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 for walkTokens 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.

@0E9B061F
Copy link
Contributor Author

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).

@pablo-abc
Copy link
Owner

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.

@0E9B061F
Copy link
Contributor Author

I gave it a shot but I'm not very familiar with typescript. You should double check that.

@0E9B061F
Copy link
Contributor Author

Added documentation of the feature to the readme, too.

Copy link
Owner

@pablo-abc pablo-abc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect! Thanks a lot!

@pablo-abc pablo-abc merged commit 00301f3 into pablo-abc:main Jul 21, 2022
@0E9B061F
Copy link
Contributor Author

No problem! Glad to help.

@ZerdoX-x ZerdoX-x mentioned this pull request Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants