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

Make rendering configurable / or how? #73

Open
enthus1ast opened this issue Jul 24, 2024 · 1 comment
Open

Make rendering configurable / or how? #73

enthus1ast opened this issue Jul 24, 2024 · 1 comment

Comments

@enthus1ast
Copy link

How could one change the rendering of some elements?
So how, for example, could i add css classes to some elements, that they fit nicely into my website?

@pietroppeter
Copy link
Contributor

Right now the process to create html from markdown is like this:

  • you start with a MarkdownConfig (a bunch of specialized Inline and block parsers)
  • a document is parsed with the config and tokens are produced
  • document is rendered which means you call $ method on the token

Say you want to add an anchor (with a slug), to all headings. You would need to:

  • create a new LinkableHeadingToken (e.g. inherit from current Heading) with your custom $ method
  • create new parsers that work in the same way current m heading generating parsers (there is two of them) but generate your new token (maybe you can inherit from them)
  • create a new config with your custom heading parsers and use those in markdown call

I think this process could be streamlined for cases like the above by allowing in markdown proc an additional pipeline that can process and modify the tokens.

Have not tried that yet, there might be additional details I am missing.

I have been thinking about this for a while, thanks for the opportunity to take a stab at writing it down. :)

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