-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add processAllTokens hook #3114
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Ok, so this is a "middle Process" hook along the lines of Preprocess and Postprocess? I like that. Does this also give access to the |
Yes it would. It is passed the |
Adding to this then: is there a benefit to splitting into two hooks? one immediately after block tokens, and another immediately after inline tokens? I'm thinking of a case where you might want to alter the block-level tokens before their internal tokens get lexed. |
A hook that captures block tokens before creating the inline tokens will need to take a bit more thought because of the way we do async marked. The hook will have to be in the I think it could be done in another PR. |
@calculuschild should I rename this to allTokens so we can add blockTokens later? |
Yeah, probably a good idea. I might suggest we use a verb like we have with the other steps, i.e. "preprocess", "walktokens", "parse", etc.
Maybe "ProcessTokens" or something? Or like, ProcessBlockTokens, ProcessAllTokens. Something like that? |
Ya I think I like processAllTokens then we can do processBlockTokens later |
# [11.1.0](v11.0.1...v11.1.0) (2023-12-12) ### Features * add processAllTokens hook ([#3114](#3114)) ([faae243](faae243))
For reference, this also solves #2639 and proves mind communication. |
Marked version: 11.0.0
Description
Add
tokens
hook that receives all tokens and can change the tokens.This hook can allow extensions that change all tokens before walkTokens functions are called. For example an extension that adds the parent and sibling properties to tokens.
Contributor
Committer
In most cases, this should be a different person than the contributor.