Option to default to line-number for all code blocks
See original GitHub issueHey @LeaVerou,
so I am using your awesome prism syntax highlighter for my blog. I would like all code blocks to have line numbers (with maybe the occasional one without line numbers).
I think it would be pretty awesome to add some kind of config to set the line-number plugin into a default-on state. In this state, the plugin would always add line-numbers, apart from the code blocks where the class .no-line-numbers
is added.
Adding the .line-numbers
class for every code-block has the following disadvantages in some cases:
- if done automatically, you can not unset it
- I am using markdown files, which are parsed by the php commonmark and it is not so easy to automatically change the behavior to always add
line-numbers
. As they are sticking to the commonmark specs, I don’t think they should change their behaviour, so it would be much simpler to add it to prism.
Issue Analytics
- State:
- Created 8 years ago
- Comments:15 (10 by maintainers)
Top Results From Across the Web
1 Code::Blocks Project Management
The display of line numbers in Code::Blocks can be activated via 'Settings' →'General Settings' in the field 'Show line numbers'. The shortcut Ctrl-G...
Read more >How to enable line numbers in minted for code blocks with ...
I would like to continue using the default setting in the code above, but I want to be able to enable line numbers...
Read more >Line numbers for every cell in VSCode Jupyter Notebook Cells
In VS Code Jupyter Notebook, you can toggle line numbers by pressing L. The trick is to select the current cell first.
Read more >Code blocks - Fork of Material for MkDocs - Jim Andreas intro
Line numbers can be added to a code block by using the linenums="<start>" option directly after the short name, whereas <start> represents the...
Read more >Number lines in code blocks with Rmarkdown - Atusy's blog
See ?rmarkdown::html_document for available highlight options. --- title: Line numbers with Rmarkdown documents output ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @LeaVerou I have been thinking about this a bit:
<article>
feels like configuration to meThe Prism object could have a small config method, which only has a getter and setter (no other logic). This way any plugin (also thrid-party plugins) could have the user add configs and retrieve it in the plugin to deal with it. Of course, there should be sensible defaults, so that the “load a go” way of using Prism, that you have going now, still works.
I really like the idea of just adding a js and css file and everything starts automatically, thus I would say it should still work. But if feel Prism is at a point, where this approach needs to be extended because whenever you actually want to do some more “advanced” stuff, its getting a little hard.
Actually, it doesn’t need to be repos under PrismJS, it could be any repo, as long as we store its info in components.js. That way people can push fixes to their plugins without requiring our approval, and we can still offer a nice build with everything from the Prism page. Unfortunately, I don’t have the time to work on this, but perhaps @Golmote or @zeitgeist87 do?