Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@shikijs/markdown-it: code block is wrong when entering a non-existent language #687

Closed
3 of 5 tasks
Only566 opened this issue May 30, 2024 · 2 comments
Closed
3 of 5 tasks

Comments

@Only566
Copy link
Contributor

Only566 commented May 30, 2024

Validations

Describe the bug

Code block is wrong when entering a non-existent language, even if the input is not complete, an error will be reported.
image
image

Allowing configuration of a default language during initialization may be a good solution.

MarkdownItPluginShiki({
  defaultLang: 'text'
})

Reproduction

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@antfu
Copy link
Member

antfu commented May 31, 2024

PR welcome :)

antfu pushed a commit that referenced this issue Jun 2, 2024
renovate bot referenced this issue in r4ai/r4ai.dev Jun 2, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [shiki](https://togithub.com/shikijs/shiki)
([source](https://togithub.com/shikijs/shiki/tree/HEAD/packages/shiki))
| [`1.6.1` ->
`1.6.2`](https://renovatebot.com/diffs/npm/shiki/1.6.1/1.6.2) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/1.6.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/1.6.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/1.6.1/1.6.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/1.6.1/1.6.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>shikijs/shiki (shiki)</summary>

### [`v1.6.2`](https://togithub.com/shikijs/shiki/releases/tag/v1.6.2)

[Compare
Source](https://togithub.com/shikijs/shiki/compare/v1.6.1...v1.6.2)

#####    🚀 Features

- **markdown-it**: Support default and fallback lang
[#&#8203;687](https://togithub.com/shikijs/shiki/issues/687)  -  by
[@&#8203;Only566](https://togithub.com/Only566) and **winnliu** in
[https://github.com/shikijs/shiki/issues/689](https://togithub.com/shikijs/shiki/issues/689)
and
[https://github.com/shikijs/shiki/issues/687](https://togithub.com/shikijs/shiki/issues/687)
[<samp>(3281b)</samp>](https://togithub.com/shikijs/shiki/commit/3281bf5b)

#####     [View changes on
GitHub](https://togithub.com/shikijs/shiki/compare/v1.6.1...v1.6.2)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/r4ai/r4ai.dev).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@rglover
Copy link

rglover commented Jun 2, 2024

This can be resolved if you add a fallbackLanguage to the options like so:

md.use(await Shiki({
  fallbackLanguage: 'javascript',
  defaultLanguage: 'javascript',
  themes: {
    light: 'slack-ochin',
  }
}));

Just tested against latest v1.6.2 release and can confirm it falls back as expected when you have non-existent language (or a typo in the language name).

@antfu antfu closed this as completed Jun 3, 2024
diegohaz referenced this issue in ariakit/ariakit Jun 12, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [shiki](https://togithub.com/shikijs/shiki)
([source](https://togithub.com/shikijs/shiki/tree/HEAD/packages/shiki))
| [`1.6.1` ->
`1.6.4`](https://renovatebot.com/diffs/npm/shiki/1.6.1/1.6.4) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/1.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/1.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/1.6.1/1.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/1.6.1/1.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>shikijs/shiki (shiki)</summary>

### [`v1.6.4`](https://togithub.com/shikijs/shiki/releases/tag/v1.6.4)

[Compare
Source](https://togithub.com/shikijs/shiki/compare/v1.6.3...v1.6.4)

#####    🚀 Features

- Add CSS variables for markup diff tokens  -  by
[@&#8203;SamyPesse](https://togithub.com/SamyPesse) in
[https://github.com/shikijs/shiki/issues/698](https://togithub.com/shikijs/shiki/issues/698)
[<samp>(84c0b)</samp>](https://togithub.com/shikijs/shiki/commit/84c0b539)
- **rehype**: Support default language option  -  by
[@&#8203;fuma-nama](https://togithub.com/fuma-nama) and
[@&#8203;antfu](https://togithub.com/antfu) in
[https://github.com/shikijs/shiki/issues/692](https://togithub.com/shikijs/shiki/issues/692)
[<samp>(724b4)</samp>](https://togithub.com/shikijs/shiki/commit/724b410e)

#####     [View changes on
GitHub](https://togithub.com/shikijs/shiki/compare/v1.6.3...v1.6.4)

### [`v1.6.3`](https://togithub.com/shikijs/shiki/releases/tag/v1.6.3)

[Compare
Source](https://togithub.com/shikijs/shiki/compare/v1.6.2...v1.6.3)

#####    🚀 Features

- **twoslash**: Add line query rendering option for twoslash renderer
 -  by [@&#8203;hddhyq](https://togithub.com/hddhyq) and
[@&#8203;antfu](https://togithub.com/antfu) in
[https://github.com/shikijs/shiki/issues/695](https://togithub.com/shikijs/shiki/issues/695)
[<samp>(aea25)</samp>](https://togithub.com/shikijs/shiki/commit/aea25115)

#####     [View changes on
GitHub](https://togithub.com/shikijs/shiki/compare/v1.6.2...v1.6.3)

### [`v1.6.2`](https://togithub.com/shikijs/shiki/releases/tag/v1.6.2)

[Compare
Source](https://togithub.com/shikijs/shiki/compare/v1.6.1...v1.6.2)

#####    🚀 Features

- **markdown-it**: Support default and fallback lang
[#&#8203;687](https://togithub.com/shikijs/shiki/issues/687)  -  by
[@&#8203;Only566](https://togithub.com/Only566) and **winnliu** in
[https://github.com/shikijs/shiki/issues/689](https://togithub.com/shikijs/shiki/issues/689)
and
[https://github.com/shikijs/shiki/issues/687](https://togithub.com/shikijs/shiki/issues/687)
[<samp>(3281b)</samp>](https://togithub.com/shikijs/shiki/commit/3281bf5b)

#####     [View changes on
GitHub](https://togithub.com/shikijs/shiki/compare/v1.6.1...v1.6.2)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ariakit/ariakit).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants