Closed qwqoffice closed 6 years ago
OK, I will try it
@qwqoffice I managed to add line numbers in the following way.
Wrap each line of code in <span class='enumerate'></span>
and then apply the following style.
pre.hljs:before {
counter-reset: listing;
}
pre.hljs span.enumerate {
counter-increment: listing;
}
pre.hljs span.enumerate::before {
content: counter(listing) " ";
display: inline-block;
}
Good luck.
I had to handle line numbers in another project, this is how I solved with it just CSS: https://codepen.io/allejo/pen/eKzydQ
Hi All,
That's the way to do it. It is very easy to wrap the lines returned by highlight.php in markup that renders the line numbers. Adding the line numbers with CSS gives the benefit that you still can copy/paste the code without getting the line numbers as well.
If you use an
Since #28 asked for this same feature, I've added demo/line-numbers.php showing why this functionality isn't necessary as part of the core and how you can achieve it yourself.
Nope.
This project is a direct and loyal port of the JS project. Since the JS project doesn’t support line numbers by choice, this project doesn’t support them as well.
Line numbers would have to be accomplished by manually with your own code or a separate project.