learnxinyminutes-site
learnxinyminutes-site copied to clipboard
Enhancement suggestion: user-supplied syntax highlighting rules/logic
Just found this project, it's cool.
There seems to be a small but steady flow of bug reports regarding highlighting issues.
I'm not quite able to tell how redcarpet and Pygments split the task of syntax highlighting, but they/it seem(s) more suited toward well-established languages with clearly-disseminated ideas of what bits should be what color. This particular site has attracted a small proportion of obscurer, more experimental languages.
IMHO, this is a good problem to have :) - some might dismiss the the fringe programming scene as a waste of time and its byproducts as junk, but since a purely academic approach already hit the 99% mark 61 years ago with Lisp, it seems like experimentation is how we'll unearth the practical and useful parts of the other 99%. So, supporting and encouraging everything is going to waste an unknown quantity of time, but it's very important.
With this in mind, a potentially interesting, scalable solution to supporting new and as-yet unknown fringe languages could be to allow the community to contribute its own syntax highlighting functionality that would be run by the server when code written in a given language is updated on GitHub.
The reason I suggest the idea of a generic code sandbox is that such systems are generally set up/shouted at just the once, and then generally remain rock solid; the basic techniques are battle-tested; and there is much discussion of implementation thanks to the profusion of online code evaluation platforms of all kinds, which must deal with all manner of attacks.
I can see such a system potentially encouraging language designers to do real-world headscratching and try and figure out how to make their new language syntax highlight itself. :D
Naturally, contributors would be encouraged to test their implementations on their own systems before uploading the final product to "production", which would then be able to simply apply changes immediately, creating a good feedback loop where further bugs in the fixes would be quickly reported.
I did a little digging; I can't figure if you're on DigitalOcean (your IP address is apparently using DO for its ISP) or Linode (an MX query points to some Linode mail servers), but apparently DO enabled nested KVM literally less than one month ago (!) (see very last post) for their NYC regions, so that could be one possible idea.
I'm imagining something based on the likes of Alpine Linux, since its base images are so small. (You could probably replace its kernel image with a much smaller one though - the kernels I build for KVM are around 1MB). You might start QEMU your own -kernel
and a user-supplied -initrd
with perhaps the input file attached to -hda
and a 1MB empty -hdb
available to the code to echo the syntax-highlighted output to. (Pass in a file via -hda
, you can cat /dev/sda
to read it.)
I love this specific kind of intricate castle-building :) - feel free to lift various parts, or disregard completely.
Many thanks for setting this site up, and coordinating the process of keeping it updated via GitHub.