grapegrip / wool

Preview Github Markdown Offline
Other
43 stars 5 forks source link

Syntax highlighting in the backend #11

Open LordMZTE opened 3 years ago

LordMZTE commented 3 years ago

Currently, wool uses PrismJS (in the frontend) to do syntax highlighting.

This seems like a rather clunky approach, as it is slow (it's js after all), reliant on the browser (making the HTML file less flexible) and it also doesn't even seem to support all that many languages.

I suggest, that we alternatively use the syntect crate which has a convenient HTML output module which we could use to generate syntax highlighting in rust. The syntect crate is also easily expandable, as it allows adding language support using sublime syntax definitions.

I am willing to help implement this, as this project looks really promising, but currently pretty unfinished.

If we implement this, we could also enable syntax highlighting by default!

grapegrip commented 3 years ago

Open to a PR. In addition to syntect, you may also want to look into tree-sitter, as this seems what Github uses.

LordMZTE commented 3 years ago

treesitter seems interesting! I've actually written a project a bit like wool before, except it can also serve non-markdown files with syntax highlighting, so maybe we could take some code from that. https://github.com/lordmzte/ultiserve

grapegrip commented 3 years ago

I actually wanted to be able to serve files from /src so that could be pretty nice!

The upstream version is actually already going in this direction (allows linking/rendering other markdown files), so open to non-markdown files as well (something like a Github-style directory preview that allows serving non-markdown files).