-
Notifications
You must be signed in to change notification settings - Fork 169
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
Add syntax highlighting for all code snippets across all languages #5331
Comments
Thank you for reporting us your feedback! The internal ticket has been created: https://warthogs.atlassian.net/browse/WD-14575.
|
The example code snippets (support syntax highlighting for HTML, JS, CSS), because they use Prism to highlight their source (here's where we call it). We could do this for |
Adding to my initial exploration: Prism.highlightAllUnder, which is the function we call to highlight syntax, relies on the We set this ourselves for examples here. Coincidentally, it seems like Jinja is not a valid option here, which is why the macros in #5321 have no syntax highlighting. It's a bit harder to apply to the whole site as we would have to set the language manually (or otherwise detect it), so we can add the class name accordingly. I started with this as a brief exploration, and found that it doesn't highlight anything because the language class is not present. (function () {
function setupPreCodeHighlights() {
if (!Prism) return;
document.querySelectorAll('pre code').forEach(Prism.highlightAllUnder);
}
document.addEventListener('DOMContentLoaded', setupPreCodeHighlights)
})(); So, what we probably need is to either find a way to detect languages (which is probably full of errors and false identifications), or to manually set the language on all of our Edit: it's also possible that my example didn't work because I was calling highlight on "code" rather than "pre" |
Triage: This seems quite high effort. Not sure how useful it is to explore more in current codebase and docs. Needs discussion. |
Triage: not worth exploring in current codebase. We could consider it when looking at new architecture documentation considerations. |
The code snippet blocks used across the website should all be syntax highlighted for their appropriate languages. Right now, only snippets on certain pages are syntax highlighted, while others are not:
https://vanillaframework.io/docs/building-vanilla
There's probably an additional CSS theme or whatnot for our syntax highlighting lib that would add this functionality.
The text was updated successfully, but these errors were encountered: