Skip to content

[Bug report] Highlighted lines break when combined with other code block options (e.g., :no-collapsed-lines) #577

@CuteReimu

Description

@CuteReimu

Description

When using code block options like :no-collapsed-lines or :collapsed-lines=N together with highlighted lines syntax (e.g., {1}), the highlighted lines feature stops working. The highlighted lines are not rendered, though other options (like collapsing behavior) still apply.

Steps to Reproduce

  1. Install Shiki plugin.

    pnpm i -D @vuepress/plugin-shiki@next
  2. In config.ts, enable Shiki plugin (either with or without extra configuration):

    import { shikiPlugin } from '@vuepress/plugin-shiki'
    export default defineUserConfig({
      plugins: [shikiPlugin({})],
    });

    We MUST enable Shiki plugin, otherwise everything works well.

  3. Use a code block with both :no-collapsed-lines (or similar) and highlighted lines syntax, for example:

    ```java :no-collapsed-lines {1}
    13213123
    ```
  4. Observe that line 1 is not highlighted, though the :no-collapsed-lines option is respected.

    If we don't add other syntax, for example:

    ```java {1}
    13213123
    ```

    Then the highlighted lines work well.

Expected Behavior

Both the :no-collapsed-lines (or :collapsed-lines=N, title="...") option and line highlighting ({1}) should work simultaneously—lines specified in {...} should be visually highlighted, while other behaviors follow the given options.

Actual Behavior

Highlighted lines are ignored when any other option (e.g., :no-collapsed-lines, :collapsed-lines=5, title="...") is present in the same code fence.

I list a minimal reproduction below.

Reproduction

https://stackblitz.com/edit/vuepress-xvki3ub9?file=docs%2FREADME.md

Used Package Manager

pnpm

System Info

info 
  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
    bun: Not Found
  Utilities:
    Git: Not Found
  Browsers:
    Chrome: Not Found
  npmPackages:
    @vuepress/bundler-vite: next => 2.0.0-rc.18 
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli: Not Found
    @vuepress/client: Not Found
    @vuepress/core: Not Found
    @vuepress/markdown: Not Found
    @vuepress/shared: Not Found
    @vuepress/utils: Not Found
    vue: ^3.5.13 => 3.5.13 
    vue-router: Not Found
    vuepress: next => 2.0.0-rc.18

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions