Support guessing lexer by filename

This commit is contained in:
2024-08-11 13:04:35 -03:00
parent b4f38e00e1
commit e3a1ce37b4
3 changed files with 30 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ Usage:
Options:
-f <formatter> Format to use (html, terminal, json)
-t <theme> Theme to use, see --list-themes [default: default-dark]
-l <lexer> Lexer (language) to use, see --list-lexers [default: plaintext]
-l <lexer> Lexer (language) to use, see --list-lexers [default: autodetect]
-o <output> Output file. Default is stdout.
--standalone Generate a standalone HTML file, which includes
all style information. If not given, it will generate just
@@ -77,7 +77,7 @@ if options["-f"]
exit 0
end
lexer = Tartrazine.lexer(options["-l"].as(String))
lexer = Tartrazine.lexer(name: options["-l"].as(String), filename: options["FILE"].as(String))
input = File.open(options["FILE"].as(String)).gets_to_end
output = formatter.format(input, lexer, theme)