Skip to content

Conversation

brc-dd
Copy link
Member

@brc-dd brc-dd commented Mar 27, 2025

BREAKING CHANGE: vp-adaptive-theme class is no longer added to code blocks when there is single theme. Theme authors supporting single code theme can use .shiki:not(.shiki-themes) as selector. Alternatively, it might be better to use the bg/fg variables set on the .shiki block to keep things generic.

BREAKING CHANGE: vp-code class is no longer added to code blocks. Use .shiki or pre.shiki or [class*='language-'] pre instead.

People not customizing their themes are not affected. But if you see weird stuff, you know what to change.

…nsformers

BREAKING CHANGE: `vp-adaptive-theme` class is no longer added to code blocks when there is single theme. Theme authors supporting single code theme can use `.shiki:not(.shiki-themes)` as selector. Alternatively, it might be better to use the bg/fg variables set on the `.shiki` block to keep things generic.

BREAKING CHANGE: `vp-code` class is no longer added to code blocks. Use `.shiki` or `pre.shiki` or `[class*='language-'] pre` instead.

People not customizing their themes are not affected. But if you see weird stuff, you know what to change.
@brc-dd brc-dd merged commit db58af5 into main Mar 27, 2025
9 checks passed
@Dedicatus546
Copy link

Are there some ways in v2.0.0-alpha.4 to avoid removing shiki styles from pre? I am creating a custom theme, and I just want to use shiki style in code block.

@Dedicatus546
Copy link

I use pnpm patch vitepress and comment out the following code in [email protected]\dist\node\chunk-BBDUp32J.js:

const transformers = [
  transformerNotationDiff(),
  transformerNotationFocus({
    classActiveLine: "has-focus",
    classActivePre: "has-focused-lines"
  }),
  transformerNotationHighlight(),
  transformerNotationErrorLevel(),
  // {
  //   name: "vitepress:add-class",
  //   pre(node) {
  //     this.addClassToHast(node, "vp-code");
  //   }
  // },
  // {
  //   name: "vitepress:clean-up",
  //   pre(node) {
  //     delete node.properties.style;
  //   }
  // }
];

@brc-dd
Copy link
Member Author

brc-dd commented Mar 28, 2025

You can use the nightly releases - pnpm add -D https://pkg.pr.new/vitepress@db58af5

@brc-dd brc-dd deleted the fix/shiki-cleanup branch March 28, 2025 09:26
@Dedicatus546
Copy link

Thanks! It looks better. Will the next alpha version include this PR?

@brc-dd
Copy link
Member Author

brc-dd commented Mar 28, 2025

Yes.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants