Skip to content

feat(rehype): add onFallback callback option#1250

Open
dan-lee wants to merge 1 commit intoshikijs:mainfrom
dan-lee:feat/rehype-on-fallback
Open

feat(rehype): add onFallback callback option#1250
dan-lee wants to merge 1 commit intoshikijs:mainfrom
dan-lee:feat/rehype-on-fallback

Conversation

@dan-lee
Copy link
Copy Markdown
Contributor

@dan-lee dan-lee commented Feb 25, 2026

  • <- Keep this line and put an x between the brackts.

Description

When using fallbackLanguage there's no way to know when a fallback actually happens, making it hard to detect typos in language identifiers or missing grammars.

Adds an onFallback callback to rehype options:

onFallback?: (context: { requestedLanguage: string; fallbackLanguage: string }) => void

So it can be used liked this:

rehypeShikiFromHighlighter(highlighter, {
  fallbackLanguage: "text",
  onFallback({ requestedLanguage, fallbackLanguage }) {
    console.warn(`Language "${requestedLanguage}" not found. Falling back to "${fallbackLanguage}"`);
  },
});

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 25, 2026

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit 50d997d
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/699ea3c5a71acf0008778dbb
😎 Deploy Preview https://deploy-preview-1250--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 25, 2026

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit 50d997d
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/699ea3c59eded700089faaf6
😎 Deploy Preview https://deploy-preview-1250--shiki-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.26%. Comparing base (2b33c0c) to head (50d997d).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
packages/rehype/src/core.ts 54.54% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1250      +/-   ##
==========================================
- Coverage   95.26%   95.26%   -0.01%     
==========================================
  Files          92       92              
  Lines        8032     8040       +8     
  Branches     1714     1716       +2     
==========================================
+ Hits         7652     7659       +7     
- Misses        374      375       +1     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dan-lee dan-lee force-pushed the feat/rehype-on-fallback branch from d8aceb0 to 50d997d Compare February 25, 2026 07:24
@dan-lee
Copy link
Copy Markdown
Contributor Author

dan-lee commented Feb 25, 2026

I don't understand the issues from codecov.
I had to change these lines because the linter complained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant