Closed Delta456 closed 5 months ago
Also noticing the issue, particularly with PHP and html, with any any combination of PHP or html being the root.
@Delta456 the delegating lexer is working as intended. If you read the documentation it describes how it works, in that the root lexer must return a token type of Other
. Neither Go or Python are designed for this, and I'm not sure how that would even work.
@isabelroses if you find a bug please file an issue. There are tests for the delegating lexer, and the "phtml" lexer uses it directly and nobody has filed any bugs for a few years, but anything's possible.
@Delta456 the delegating lexer is working as intended. If you read the documentation it describes how it works, in that the root lexer must return a token type of
Other
. Neither Go or Python are designed for this, and I'm not sure how that would even work.
That's true indeed. Can you add an explicit list of supported explicit languages for DelegatingLexer
?
No, but if you wish to send a PR with an update to the README I'd consider it.
Is there an existing issue for this?
Describe the bug
I am currently working on a feature for
charmbracelet/freeze
which makes use of thechroma
library and I am using theDelegatingLexer
where I am passing two languagespy
andgo
as thelanguage
androot
respectively. My PR implementation can be seen here: https://github.com/charmbracelet/freeze/pull/79Using
./freeze --language py,go file.py
gives./freeze --language go,py file.py
givesAs it can be seen
chroma
doesn't highlight theroot
of thelexers.DelegatingLexer
. Only thelanguage
part is highlighted. However, this is not always the case../freeze --language jinja,html file.jinja
gives./freeze --language jinja file.jinja
givesIn this case,
jinja,html
languages correctly highlight the code snippet.To Reproduce
Chroma Playground doesn't support syntax highlighting of two languages at one time.
To locally reproduce this:
go build .
./freeze --language py,go file.py
Contents of
file.py
: