Comment by Shorel
1 year ago
As an experiment, it is awesome. We should strive to push the limits of technology and try new things. Kudos. I tip my hat to the creativity.
As something practical, the author started with the wrong tool for the job (JavaScript), and then used an even more wrong tool for the same job (The font itself!)
Just use a code editor with Syntax Highlighting! Vim solved this decades ago!
Very interesting read, but don't try this at home.
Edit: Pandora's box is opened, I can see Jira and GitHub rushing to add support for this on their websites starting tomorrow =)
How does a code editor solve syntax highlighting on the web?
- but the opposite: this one have such potential that you could possibly just use the font with language-specific syntax embeded and forget any other syntax highlighting (to some limits) on web (JS), console (in.. VIM) or wherever - as obsolete (in any program that did not have any syntax highlighting before - just use that font for that language and solved ) ;)
- and then with hardware accelerated font rendering https://news.ycombinator.com/item?id=41251199 ??
( ! ! ! )
Just displaying text with syntax highlighting is a solved issue.
I read such code every day in github and similar tools.
> Just use a code editor with Syntax Highlighting! Vim solved this decades ago!
You are aware that this blog post is about displaying syntax highlighted code on the web? This is literally explained in the first paragraphs of the blog post..
As of now there were four ways of doing that:
1. using an image (which sucks)
2. manually setting the colors (good luck)
3. Generating the syntax highlighting server-side (preferred, but you need a backend that can do it)
4. Generating it client side using JS (waste of energy, takes a time to finish)
And now a font. Depending on the use case this could be a feasible option, although I am just waiting for this to be exploited in some fashion.
I still think computing once styling later is preferable.
The new CSS Highlights API isn't implemented everywhere yet, but will be. See one current thread here: https://news.ycombinator.com/item?id=41251336
There's this article on using css highlights for syntax highlighting:
https://frontendmasters.com/blog/syntax-highlighting-with-no...
Yes, and I still believe editing text is painful on a browser and this is just putting lipstick on a pig.
Keyboard shortcuts and auto-complete being important pain points.
This is for publishing web pages talking about code.
The author would like to hand code HTML for such web pages that would present syntax highlighted code to the web page reader, without requiring or resorting to typical js highlighting or screenshots.
None of editing in the terminal, nor an IDE, nor a browser are related to this use case.
1 reply →