templ
templ copied to clipboard
misc: Write a lexer for Pygments
This isn't really a code change to this repo, but thought it would be worth tracking here.
What
Write a lexer for the Pygmens syntax highlighting tool.
There's a guide here on how: https://pygments.org/docs/lexerdevelopment/
And it may be useful to reference both the Go and HTML lexers:
https://github.com/pygments/pygments/blob/master/pygments/lexers/go.py
https://github.com/pygments/pygments/blob/master/pygments/lexers/html.py
Why
Pygmens is the syntax highligher that Github uses, so completing this would make for some colourful code in the github web app.
This would also enable templ support in https://github.com/alecthomas/chroma, which would be nice for server side syntax highlighting in Go.
Side chat - the number of syntax highlighting formats to support is currently at 4 - Treesitter (Neovim), Pygments (Github), TextMate (VS Code), and the JetBrains one (can't remember what that is).
I was wondering if there was a meta tool that can write syntax highlighting for all the targets. Ideally, some sort of programming language based thing that is testable.
Having that might make the problem worse due to the abstraction, I was just wondering!
Looking at https://github.com/github-linguist/linguist/pull/6435/files it looks like Github uses Textmate, as per VS Code?
Agreed... it's becoming a bit of a risk for changing the language design, having to go and update all the parsers!
Textmate rings a bell, I believe that may also work with jetbrains for https://github.com/templ-go/templ-jetbrains
There is also the prism.js syntax highlighter for the docs.
Ah yes, thanks! I think it could be possible to swap out the docs to use https://shiki.matsu.io which also uses TextMate.
There's a Docusaurus plugin, but I took a look at your templ documentation site, and it's started to look amazing, so maybe we won't need it. ;)
Github uses Linguist, so I will close this as we have a PR in for linguist.