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

WithPre refactor #91

Closed
4 of 5 tasks
brendt opened this issue Apr 3, 2024 · 1 comment
Closed
4 of 5 tasks

WithPre refactor #91

brendt opened this issue Apr 3, 2024 · 1 comment
Milestone

Comments

@brendt
Copy link
Member

brendt commented Apr 3, 2024

The current WithPre interface has a number of problems:

  • It's an awkward name, I want to come up with a better one
  • Maybe it's better to get rid of this interface altogether and have all themes return their wrapping tags that can be used within a web context
  • Themes have no inclination about the current language, making it impossible to add the data-language attribute (Adds data-lang attribute for CommonMark code block renderer #90) to the pre tags

My proposal:

  • Get rid of WithPre
  • Introduce an interface WebTheme, similar to TerminalTheme, but this one requires implementations for preBefore and preAfter
  • Find better names for preBefore and preAfter
  • Inject the highlighter into these two methods, so that we can access the current language (and other data if needed)
  • With the addition of WebTheme, we can consider moving escape logic to the theme itself instead of managing it within the highlighter.
@brendt brendt added this to the v2 milestone Apr 3, 2024
@brendt
Copy link
Member Author

brendt commented Apr 3, 2024

@aidan-casey what are your thoughts on this idea?

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

1 participant