Skip to content

How to show line numbers for code blocks rendered using the echo option? #1256

Answered by Fil
hopezh asked this question in Q&A
Discussion options

You must be logged in to vote

We're using highlight.js whose author is quite allergic to line numbers. There is a line number plugin but plumbing it (or something equivalent) into the call to hljs is not immediate (it happens in html.ts).

Looking at how to use CSS counters to make this work, it appears that the only requirement is to wrap each line into its own DOM element (where currently we're just relying on line feeds). Then a bit of CSS would do the trick.

Feel free to open a feature request (or better yet, a pull request if you manage to make it work!).

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hopezh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants