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

Highlighting more than 2 separate lines when importing code snippets produces "Invalid code snippet option" error #2546

Closed
1 task done
adamdehaven opened this issue Jul 30, 2020 · 1 comment

Comments

@adamdehaven
Copy link
Contributor

  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

  1. Save a new code snippet to .vuepress/public/snippet.js with any content. Here's an example:
const name = 'First Last'

// Create person object
let person = {
    name: name,
    email: '[email protected]'
}
  1. Import code snippet in a Markdown file with lines highlighted: <<< @/.vuepress/public/snippet.js{2-4,6}
  2. Serve project locally with npm run dev (or whatever your serve command is to run vuepress dev)
  3. See error message: "Invalid code snippet option"

What is expected?

Code should be imported with highlighted lines.

What is actually happening?

Code import fails with message:

Invalid code snippet option

Examples:

  • <<< @/.vuepress/public/snippet.js - ✔️ Works (no highlighted lines)
  • <<< @/.vuepress/public/snippet.js{2} - ✔️ Works (1 highlighted line)
  • <<< @/.vuepress/public/snippet.js{2,4} - ✔️ Works (2 highlighted lines)
  • <<< @/.vuepress/public/snippet.js{2-4} - ✔️ Works (1 range of highlighted lines)
  • <<< @/.vuepress/public/snippet.js{2,4,6} - ❌ Fails (3 highlighted lines)
  • <<< @/.vuepress/public/snippet.js{2-4,6} - ❌ Fails (1 range of highlighted lines and 1 single line)

Other relevant information

  • Code highlighting works property in regular code blocks
  • Output of npx vuepress info in my VuePress project:
Environment Info:

  System:
    OS: Windows 10 10.0.16299
    CPU: (8) x64 Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
  Binaries:
    Node: 10.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 41.16299.1480.0
  npmPackages:
    @vuepress/core:  1.5.2
    @vuepress/theme-default:  1.5.2
    vuepress: ^1.5.2 => 1.5.2
  npmGlobalPackages:
    vuepress: Not Found
@adamdehaven
Copy link
Contributor Author

Fixed with #2441

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

No branches or pull requests

1 participant