Repository navigation
fix(cli): fall back to plaintext for unknown languages - #1319
Merged
Merged
Conversation
When used as a cat replacement, unknown extensions such as `.env.example` (`example`) should print the file instead of throwing. Keep the empty-extension fallback from shikijs#1248, and resolve unknown langs to `text` when they are not bundled and not a special language.
â Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
â Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Reportâ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1319 +/- ##
=======================================
Coverage 89.88% 89.88%
=======================================
Files 81 81
Lines 3589 3589
Branches 1028 1026 -2
=======================================
Hits 3226 3226
Misses 326 326
Partials 37 37 â View full report in Codecov by Harness. ð New features to boost your workflow:
|
The extracted helper narrowed theme to string, which failed vue-tsc against codeToANSI.
`it.compare` is no longer on TestAPI; compare lives on the bench fixture. This unblocks typecheck, which is already red on main.
âĶfallback # Conflicts: # bench/bundle-test/bundle.bench.ts # bench/engines/engines.bench.ts
antfu
pushed a commit
to SHUBHI-KUMARI/shiki
that referenced
this pull request
Oct 1, 2026
Co-authored-by: Anthony Fu (via agent) <reg-github-bot@antfu.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xbetween the brackts.Description
@shikijs/clicurrently treats the file extension as a language id. For names like.env.example, that becomesexample, which is not a bundled language, so Shiki throws and the file is never printed.When the CLI is used as a
catreplacement (skat), unknown languages should always still print the file. This keeps the empty-extension fallback from #1248 (options.lang || ext || 'text') and adds the missing branch: if the resolved lang is not inbundledLanguagesand is not a special language (text/txt/plain/ansi/plaintext), highlight astext.This is the same idea as
@shikijs/rehype'sfallbackLanguage, scoped to the CLI. Core still throws for unknown languages (#333). Grammar load/parse failures for known languages are not swallowed. No shebang/content guessing (#1258). Compound suffix mapping (.env.exampleâdotenv) is intentionally out of scope.Linked Issues
Additional context
Regressions cover:
.env.example/ unknown extension â print file, no throwMakefile(no extension) â stilltext(no fix(cli): fall back to 'text' when file/URL has no extension and no -âĶ #1248 regression)README.md/.tsâ still highlighted--lang dotenv file.env.exampleâ explicit lang wins--langâ stilltext