Handle unknown lexer, remove dead _THEMES list, tighten JSON detection - Catch unknown Pygments lexer names and fall back to plain text - Remove unused _THEMES list from cli.py - Only auto-detect JSON when content starts with { or [ to avoid false positives on trivial values like strings or numbers
This commit is contained in:
@@ -73,10 +73,12 @@ def detect_type(
|
||||
return EXTENSION_MAP[suffix]
|
||||
|
||||
if content is not None:
|
||||
try:
|
||||
json.loads(content[:1000])
|
||||
return "json"
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
pass
|
||||
stripped = content.lstrip()
|
||||
if stripped and stripped[0] in ("{", "["):
|
||||
try:
|
||||
json.loads(stripped[:1000])
|
||||
return "json"
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
pass
|
||||
|
||||
return "text"
|
||||
|
||||
Reference in New Issue
Block a user