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

non-css syntax highlighting doesn't work (and is fixed to one theme) #320

Closed
faassen opened this issue May 24, 2024 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@faassen
Copy link
Contributor

faassen commented May 24, 2024

Bug Report

Environment

Zola version: 0.18.0
tabi version or commit: c54251c

Expected Behavior

In the [markdown] section I used the following

highlight_code = true
highlight_theme = "gruvbox-light"

The themes are listed here:

https://www.getzola.org/documentation/getting-started/configuration/#syntax-highlighting

Eventually after doing some web searches I found out that tabi only supports the css-based (classed highlighting) system as documented here:

https://www.getzola.org/documentation/content/syntax-highlighting/#inline-vs-classed-highlighting

Now the syntax highlighting works but I'm still locked into the theme supplied by tabi. I think I can get around that but only by changing the theme directly.

What I would expect is that non-css themes just work out of the box. The zola documentation says using it will make your page load faster, as there's no dependency on an external file.

If this can't be supported, I expect some documentation somewhere saying that it isn't and what to do. I would also expect some way to configure the used CSS theme; I think right now everyone is locked into syntax-ayu-dark.scss. Maybe it's possible to override main.scss to change this but I don't know how.

In an ideal world it would also implement light/dark mode aware CSS theming (as discussed here.)

Current Behavior

No syntax highlighting appeared. I could see style tags being added to the generated code, but these don't show up for some reason.

Step to Reproduce

Just write any block that has syntax highlighting with the above confirmation.

PS

These issues make it seem like I'm complaining a lot. I am enjoying tabi; I'm just reporting issues I struggled with.

@faassen faassen added the bug Something isn't working label May 24, 2024
@welpo
Copy link
Owner

welpo commented May 24, 2024

These issues make it seem like I'm complaining a lot. I am enjoying tabi; I'm just reporting issues I struggled with.

Not at all! I appreciate these; I take it as a sign of care—noticing imperfections.

I could see style tags being added to the generated code, but these don't show up for some reason.

You mean you could see the styling tags (e.g. <span style="color:#d08770;">)?

If so, chances are the styling is not loading due to tabi's default strict Content Security Policy. You could try disabling it or allowing inline styles with this line:

{ directive = "style-src", domains = ["'self'", "'unsafe-inline'"] },

Let me know whether this fixes the issue!

@faassen
Copy link
Contributor Author

faassen commented May 24, 2024

Ah, yes, I did see the inline style tags! I'll give that a shot, thanks! I didn't realize inline styles could be considered unsafe.

@faassen
Copy link
Contributor Author

faassen commented May 26, 2024

I would be good if the docs could mention this I think, by the way. Oh wait I still have to try whether this fixes things first.

@faassen
Copy link
Contributor Author

faassen commented May 26, 2024

I just tried it and it works.

I checked the generated HTML source and I think it's not loading the CSS for the CSS based syntax lighlighting anymore so that's good.

@welpo
Copy link
Owner

welpo commented May 26, 2024

Great!

I would be good if the docs could mention this I think

Agreed. I think I'll add it to the CSP page, but perhaps it would be good to mention it in the Mastering tabi post.

Where would you expect to find this info?

@faassen
Copy link
Contributor Author

faassen commented May 26, 2024

What I did is go through the tabi config file and adopt various items into my own. The comments helped here. I think a mention of this above the csp in the comment and or above highlight would have saved me.

@welpo
Copy link
Owner

welpo commented May 30, 2024

Thanks for the suggestions. I've added comments on config.toml, theme.toml above the syntax theme and the CSP directives. I've also mentioned it in the CSP demo/docs page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants