shikijs / shiki

A beautiful yet powerful syntax highlighter
http://shiki.style/
MIT License
9.19k stars 330 forks source link

feat(rehype): Support default language option #692

Closed fuma-nama closed 4 weeks ago

fuma-nama commented 1 month ago

Description

As the markdown-it integration also provides similar options, this PR adds the defaultLanguage option to the rehype integration.

When no language specified, it uses the default language instead. Note that it doesn't change the current behaviour. When neither language nor default language is provided, the code block will not be processed by Shiki, hence you can handle it on your own, and won't break existing usages.

Linked Issues

691

Additional context

unit tests are added.

netlify[bot] commented 1 month ago

Deploy Preview for shiki-matsu ready!

Name Link
Latest commit 31571dfdaf2ecc727fa6a5c17b8a2e11a153fa0b
Latest deploy log https://app.netlify.com/sites/shiki-matsu/deploys/6662f83f4f07420008b13f5d
Deploy Preview https://deploy-preview-692--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 site configuration.

netlify[bot] commented 1 month ago

Deploy Preview for shiki-next ready!

Name Link
Latest commit 31571dfdaf2ecc727fa6a5c17b8a2e11a153fa0b
Latest deploy log https://app.netlify.com/sites/shiki-next/deploys/6662f83f3ab1fe00084edcb0
Deploy Preview https://deploy-preview-692--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 site configuration.

antfu commented 1 month ago

Could you also help to implement the same interface as in https://github.com/shikijs/shiki/pull/689? Thanks!

fuma-nama commented 1 month ago

Added fallbackLanguage option