Skip to content
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

Customize Lexer and Parser #1890

Closed
janosh opened this issue Dec 24, 2020 · 4 comments
Closed

Customize Lexer and Parser #1890

janosh opened this issue Dec 24, 2020 · 4 comments

Comments

@janosh
Copy link

janosh commented Dec 24, 2020

Describe the feature

Provide the ability to customize the Lexer and Parser.

Why is this feature necessary?

Marked's current architecture is not amenable to certain extensions. I'd like to create an extension that supports custom attributes (like remark-attr and markdown-it-attrs):

# Yeah{.success}
<h1 class="success">Yeah</h1>

Currently, I can only customize the Tokenizer and Renderer. This means, the call signature for rendering e.g. a link is fixed by the Parser to be link(href, title, text) { ... }. This leaves no room for passing in another argument attrs to render any attributes.

Describe alternatives you've considered

Nothing good comes to mind.

@UziTech
Copy link
Member

UziTech commented Dec 24, 2020

Duplicate of #1693.

#1872 is trying to fix it.

@UziTech UziTech closed this as completed Dec 24, 2020
@janosh
Copy link
Author

janosh commented Dec 24, 2020

If I understand correctly, #1872 only addresses the Lexer. With that merged, I would still be unable to create a custom renderer with the ability to pass around an additional argument for attributes, no?

@UziTech
Copy link
Member

UziTech commented Dec 24, 2020

Ya the idea is that you will be able to create your own tokenizers and renderers so you will be able to pass whatever you want. I'm not exactly sure how it will work out. The current implementation is very slow. If you want to help out we could use more input on it.

@janosh
Copy link
Author

janosh commented Dec 25, 2020

I took a closer look at #1872. I'm afraid I don't understand marked internals enough to make useful speed-up suggestions. Happy to help though if there's something less sophisticated to do.

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

No branches or pull requests

2 participants