-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Syntax highlight at build time #184
Comments
Hello! Sounds good. Do you have any ideas for how we would do this? |
A quick phase 1 could be hosting the A phase 2... well, peeking at the source, it appears |
We intend to stop using mdbook in future, just not something we've got around to yet. |
For syntax highlighting at build time, the syntect library (written in Rust) could work. Deno Doc uses it for documentation. (See this package for an example: https://deno.land/x/[email protected]/application.ts) |
Another option would be to teach the compiler how to print with colours, seeing as it already knows the Gleam grammar. Avoid a large-ish dep. |
The use of highlight.js has some issues:
a. with browser sandboxing, there is no performance benefit from using a CDN in this way
b. the CDN will leak private user data such as IPs to an entity that may not act in good faith with that data
c. subresource-integrity check is also missing so this code could be insecure and changed by the CDN at will because it's not within Gleam's control
d. technically since these URLs lack the protocol, they could be served over the insecure HTTP vs. HTTPS+TLS
a. wasteful to CPU + battery
b. wasteful on the network (and user data plans)
c. introducing a rendering and paint delay
My suggestion is to render syntax highlighting at build time and include the syntax highlighting CSS into the base style sheet. This would mean the syntax highlighting step would be executed once and it would be static. Built static, this eliminates the need for JavaScript for the basic documentation, does not require consenting to third-party CDN and security risks involved with it, saves people's CPUs+batteries+data plans, and would increase render performance.
The text was updated successfully, but these errors were encountered: