slidev icon indicating copy to clipboard operation
slidev copied to clipboard

[DRAFT] feat: show line numbers in markdown blocks

Open Sdju opened this issue 1 month ago • 4 comments

Add line numbers for code blocks in Slidev VSCode extension

Motivation

I have many code blocks in my presentations. And I often need to know line numbers (e.g., for line highlighting {1|7-9...} ). It would therefore be useful to see line numbers directly in the editor.

Description

This PR adds an optional feature to display line numbers for code blocks in the Slidev VSCode extension, making it easier to reference specific lines when working with code in presentations.

Screenshots

image image

Changes

1. Line numbers decoration for code blocks

  • Added automatic line numbering for code blocks (triple backticks ```)
  • Ignores special blocks like magic-move (4+ backticks)
  • Added slidev.annotations-line-numbers setting (default: true)

Known issues

  1. Doesn't respect the startLine option
  2. Shares the same triggers for creating annotations — looks odd until the document is saved image

Sdju avatar Oct 29 '25 13:10 Sdju

Deploy Preview for slidev ready!

Name Link
Latest commit ec653bf4f8580bccdd7c3ed9e21cf8a533c05c49
Latest deploy log https://app.netlify.com/projects/slidev/deploys/69035a8acb62760008d57bf2
Deploy Preview https://deploy-preview-2320--slidev.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

netlify[bot] avatar Oct 29 '25 13:10 netlify[bot]

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2320
create-slidev

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

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2320
@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2320
@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2320
@slidev/types

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

commit: ec653bf

pkg-pr-new[bot] avatar Oct 29 '25 13:10 pkg-pr-new[bot]

Love the idea!

antfu avatar Oct 30 '25 05:10 antfu

The lint error seems to require manual update.

Fixed

Sdju avatar Oct 30 '25 12:10 Sdju