I currently enjoy the benefits of having syntax-highlighted code blocks in my articles or comments. It makes the code stand out from the rest of the text. However, there may be times when it is necessary to reference a line number in a code block for a clearer explanation of a particular line.
In that case, I open this issue to request for an option to add line numbers in code blocks. I believe this is possible with Jekyll? Knowing that Hofstadter's Law exists, I hope that it wouldn't be too hard to implement.
Perhaps line numbers can be globally enabled through the front matter?
---title: Line numbers in code blocks are cool!tags: metalinenos: true---
Or perhaps it can be enabled inline with each code block?
---title: Individual Code Block Activationtags: meta---#Example of Unactivated Code Block```javascriptconsole.log('I have no line numbers... 😟');```#Example of Inline Activation```javascript linenosconsole.log('I have inline line numbers! Yay! 🎉');```
Perhaps it could even be globally enabled by default?
Anyway, that's pretty much this entire feature request. Looking forward to the day this becomes possible! Thanks for reading!
Hi! I'm Luis 👋 I'm a frontend web dev and future effective altruist. I'm always exploring new web tech. Some times I share those practices on GitHub 🧑🔬, or write about them on DEV 🖤.
Glad to see this request back. Here's the discussion we had a couple of years back.
Feature Request: Add the option to include line numbers in code blocks #1236
I currently enjoy the benefits of having syntax-highlighted code blocks in my articles or comments. It makes the code stand out from the rest of the text. However, there may be times when it is necessary to reference a line number in a code block for a clearer explanation of a particular line.
In that case, I open this issue to request for an option to add line numbers in code blocks. I believe this is possible with Jekyll? Knowing that Hofstadter's Law exists, I hope that it wouldn't be too hard to implement.
Perhaps line numbers can be globally enabled through the front matter?
Or perhaps it can be enabled inline with each code block?
Perhaps it could even be globally enabled by default?
Anyway, that's pretty much this entire feature request. Looking forward to the day this becomes possible! Thanks for reading!
I'm glad it wasn't just me. Thanks for bring it up, Andrew!