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

lineNumbers options is not working when using Code Snippets #1754

Closed
nana4gonta opened this issue Jul 12, 2024 · 3 comments · Fixed by #1755
Closed

lineNumbers options is not working when using Code Snippets #1754

nana4gonta opened this issue Jul 12, 2024 · 3 comments · Fixed by #1755

Comments

@nana4gonta
Copy link

Describe the bug

The lineNumbers: true option displays line numbers in code blocks,
but line numbers are not displayed when imported as Code Snippets.

Minimal reproduction

Steps to reproduce the behavior:

  1. Create Project: npm init slidev@latest
  2. Open slides.md, and add the option lineNumbers: true
  3. Run npm run dev
  4. Open: http://localhost:3030/5
  5. See that line numbers are not displayed in Code Snippets

https://stackblitz.com/edit/github-fc4pne?file=slides.md

Environment

  • Slidev version: 0.49.16
  • Browser: 126.0.6478.127(Official Build) (arm64)
  • OS: macOS Sonoma 14.5
@nana4gonta
Copy link
Author

workaround

If you specify the line numbers to highlight (e.g. {1-100}) and set {lines:true}, the line numbers will be displayed.
But if you don't specify the line numbers to highlight, they will not be displayed.

Any Text...

<!-- display line numbers -->
<<< @snippets/something-code.ts {1-100}{lines: true}

<!-- not display line numbers -->
<<< @snippets/something-code.ts {lines: true}

Any Text...

@kermanx
Copy link
Member

kermanx commented Jul 12, 2024

This is an expected behavior. The first {} will always be regarded as line highlighting.

A more elegant way is:

<<< @snippets/something-code.ts {*}{lines: true}

@kermanx kermanx closed this as completed Jul 12, 2024
@nana4gonta
Copy link
Author

nana4gonta commented Jul 12, 2024

@kermanx
I only presented a workaround, the original problem has not been solved.
The problem of line numbers not being displayed in Code Snippets has not been resolved, even though lineNumbers: true is set.

See Minimal reproduction properly.
And See stackblitz
https://stackblitz.com/edit/github-fc4pne?file=slides.md

I'm expecting that if I set lineNumbers: true globally, then I import Code Snippets, the line numbers will be displayed.

Please reopen this issue.

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 a pull request may close this issue.

2 participants