mirror of
https://github.com/sharkdp/bat
synced 2026-06-09 10:03:18 +00:00
Add --fallback-syntax for undetected files (#3617)
* feat(cli): add fallback syntax option Expose a new fallback syntax CLI option so users can opt into syntax highlighting only when auto-detection fails. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * feat(syntax): apply fallback only after detection fails Use the fallback syntax only when path and first-line detection fail, preserving existing behavior for detected files and explicit language selection. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * test(cli): cover fallback syntax behavior Add integration coverage for fallback syntax usage, precedence with --language, and no-op behavior when syntax is already detected; update help snapshots for the new option. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * docs(changelog): document fallback syntax option Record the new fallback syntax feature in the unreleased changelog section. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> --------- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
committed by
GitHub
parent
ab80bd9717
commit
844bfded50
@@ -37,6 +37,13 @@ Options:
|
||||
name (like 'C++' or 'LaTeX') or possible file extension (like 'cpp', 'hpp' or 'md'). Use
|
||||
'--list-languages' to show all supported language names and file extensions.
|
||||
|
||||
--fallback-syntax <fallback-syntax>
|
||||
Set a fallback language for syntax highlighting when auto-detection fails. Unlike
|
||||
'--language', this is only used when no syntax could be detected from filename, custom
|
||||
syntax mappings, or first-line detection.
|
||||
|
||||
[aliases: --fallback-language]
|
||||
|
||||
-H, --highlight-line <N:M>
|
||||
Highlight the specified line ranges with a different background color For example:
|
||||
'--highlight-line 40' highlights line 40
|
||||
|
||||
@@ -17,6 +17,8 @@ Options:
|
||||
Show plain style (alias for '--style=plain').
|
||||
-l, --language <language>
|
||||
Set the language for syntax highlighting.
|
||||
--fallback-syntax <fallback-syntax>
|
||||
Set a fallback language for undetected syntaxes. [aliases: --fallback-language]
|
||||
-H, --highlight-line <N:M>
|
||||
Highlight lines N through M.
|
||||
--file-name <name>
|
||||
|
||||
Reference in New Issue
Block a user