Skip to content

fix: keep c#, c++ and f# languages in code blocks and magic move - #2760

Merged
antfu merged 1 commit into
slidevjs:mainfrom
NgoQuocViet2001:fix-fence-lang-hash-plus
Oct 2, 2026
Merged

antfu merged 1 commit into
slidevjs:mainfrom
NgoQuocViet2001:fix-fence-lang-hash-plus

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor

The code block info regex only accepts [\w'-] for the language, so ```c# [Program.cs] {1} is parsed as lang c plus a leftover #. The block gets the C grammar (<code class="language-c">) and also loses its title and ranges (title="", :ranges='[]'). c++ ends up as c too, and f# becomes f, which Shiki resolves to Fortran. This started in v52.15.0, when wrapping moved into the fence renderer. Before that, the markdown transform skipped these blocks and Shiki still got c#.

Magic Move has used the same character class for longer. A c# or c++ step never matches, so a block with only those steps throws "Magic Move block must contain at least one code block", and in a mixed block the step is silently dropped (```ts + ```c# gives only ['ts']).

This adds # and + to the language group in both regexes, the same kind of change #1389 made with - for angular-ts. It covers Shiki's c#, c++ and f# aliases.

  • Ran: pnpm vitest run packages/slidev/node/syntax/codeblock. Both new tests fail on main (the Magic Move error, and language-c with an empty title) and pass with the change.
  • Ran: vitest test --run (the pnpm test script) after a fresh build: 34 files and 379 tests passed.
  • Ran: pnpm lint and pnpm typecheck: both clean.

@netlify

netlify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 32c0219
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/6abf2008806e560007ef1027
😎 Deploy Preview https://deploy-preview-2760--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2760

create-slidev

npm i https://pkg.pr.new/create-slidev@2760

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2760

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2760

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2760

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2760

commit: 32c0219

@antfu
antfu merged commit 73053ab into slidevjs:main Oct 2, 2026
21 checks passed
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.

2 participants