mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.09k stars 25 forks source link

idea: allow customizing the code highlighting theme #262

Closed mikavilpas closed 1 month ago

mikavilpas commented 1 month ago

I like to use the Catppuccin Macchiato theme in my presentations as it matches my other tools (they also use the same theme). Presenterm also comes bundled with the Catppuccin Macchiato theme, so I can use it without any additional setup.

However, code highlighting in the builtin theme is set to base16-eighties.dark which looks a bit strange. I would like my presentations to use the Catppuccin Macchiato theme (from https://github.com/catppuccin/bat) for code highlighting as well.

I verified that currently I can do this by

I understand that it might be difficult to bundle the Catppuccin Macchiato code highlighting theme with Presenterm, but do you think it could be possible to allow customizing the code highlighting theme for users that are willing to install it manually?

I would be happy to contribute to this feature if you think it is a good idea.

Possible approaches

  1. Add a new configuration option for specifying the code highlighting theme.
    • if the user has configured this in their config file, use that highlighting theme instead of one in the user's theme (or the default theme if they have no theme set).
    • this could also be supported in the frontmatter of the markdown file, but personally I don't think I need it.
  2. Allow partially overriding a builtin theme.
    • this would allow users to only override the code highlighting settings while keeping the rest of the theme intact.

Maybe there is a better idea that I can't think of. Would love to hear your thoughts.

mfontanini commented 1 month ago

So just to be clear, you can already partially override a theme in the front matter by using the override key so you could do this on a per presentation basis but I understand this is annoying.

Something that I thought about implementing in the past and would fit here is being able to have themes that extend others. You could create a theme that has an

extends: catppuccin-macchiato

And this means it basically inherits everything from that theme. Then you can add the property to set the code highlighter and there's that. So this would be what you're doing except you wouldn't need to maintain it as it will always inherit everything from the base theme. Would this work for you? This seems in line with the "allow partially overriding a builtin theme" suggestion you have except it applies to any theme, not just built in.

Add a new configuration option for specifying the code highlighting theme

I don't particularly like this solution because the code highlighter theme is just one of the many properties a theme has so adding a config parameter just for this one seems strange.

mikavilpas commented 1 month ago

Yeah, that sounds really good to me. 👍🏻

mfontanini commented 1 month ago

I created #265 for this but I realized I need a topological sort to deal with theme recursion (A extends B extends C) and I ran out of time today, I'll try to finish it tomorrow. For now it works, except not if you have an extension chain ^.

mikavilpas commented 1 month ago

Thanks, this works perfectly 👍🏻