-
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
Extending with custom tags #1373
Comments
you will have to modify the lexer and parser if you want to create your own tokens. This is not something that is done easily. There have been times where a fix in marked has created a bug in someones custom parser. |
Maintainability is not a problem if I understand how the extension system exactly works. Should be good to have a basic example of all steps (renderer, parser, lexer, etc) to create new inline and block tokens in the documentation. Currently, I'm analyzing the source code to understand it, because the documentation seems incomplete to me. |
The documentation is incomplete, but we are always accepting pull requests 😁 |
You're right, but my knowledge is too low/insufficient for this right now 😅 |
Follow up question here...I have seen examples of how to modify the inlineLexer, but how to modify the main lexer with custom rules? I don't see how to add custom tokens without completely rewriting the |
@solugebefola Right now to modify the lexer you will need to rewrite |
Was there a PR to add this feature? Or just closing b/c no activity? |
Sorry I was closing all of the There have not been any PRs to address this. |
can the parser and lexer implement a similar api as the renderer to make them more extensable? |
@horacioh that would be great if they did. PRs are always welcome. 😁 |
I might work on a PR for this. There are a couple of lexer elements I want to customize how tokens are generated (tables) but I can't without rewriting the whole function. Sounds like it would be in line with the Marked architecture if I separate each lexer token into its own named item like it is in the renderer? |
@calculuschild That would be great! Just make sure that creating separate functions doesn't slow it down too much. You can run I am also working on creating inline tokens before sending them to the parser in PR #1627 |
@UziTech Alright, got an initial attempt at extending the Lexer. |
Ya I think it does. |
I want to create custom "tags", like text alignment blocks, inline text color, etc.
Documentation is not very clear to me how to create totally new tags or tokens.
There are other examples?
The text was updated successfully, but these errors were encountered: