Closed onlyphantom closed 2 years ago
Rich-CLI uses Pygments to detect the file type. This means you can install any extension you want that plugs into Pygments. To fix the highlighting issue, install the following package:
$ pip install jsx-lexer
You can then run Rich over a JSX file.
The file type must be .jsx
, the .js
lexer will still give issues if you use JSX syntax within it.
If this issue comes up again, I could probably PR an optional dependency to JSX-Lexer along with a suggestion if trying to highlight a JSX file.
Thank you for the quick reply!
I think the suggestion makes a lot of sense. If rich
is run on a file with the jsx
extension, then raise a message that ask if the user would like to install the optional jsx-lexer
?
and I understand that this is due to the way Pygment / lexer handles js file more so than rich-cli per-se
uses Pygments to detect the file type
Anyway -- closing the issue now since, as was my original consideration, it isn't something rich-cli
has to be concerned about and the problem lies further upstream.
Syntax highlighting of HTML closing tags in
.js
files seems to be wrong however, and I understand that this is due to the way Pygment / lexer handles js file more so thanrich-cli
per-se, but with js libraries such as React being so prevalent nowadays would this be an interesting area of improvement?Related to that -- maybe we could add a
jsx
as a lexer as well?