Open jalanb opened 1 year ago
Oh this is a good idea. I'm using the rich.syntax.Syntax.guess_lexer
method from Rich to handle this currently since the Syntax
class is handling almost everything else. In turn it uses pygments to handle it.
https://rich.readthedocs.io/en/stable/reference/syntax.html#rich.syntax.Syntax.guess_lexer https://github.com/juftin/browsr/blob/26a1bf3488916f3c26f96d40c8f33eabee68d358/browsr/browsr.py#L175-L184
I wonder if checking for a shebang would be a welcome addition to the upstream libraries too.
Syntax highlighting seems to br triggered by file types, i.e. file extensions. So that
fred.py
is highligghted as Python syntax. Unfortunately this means that a file called justfred
, which is executable and has#! /usr/bin/env python
on the first line is not recognised, hence not highlighted.