prism: Option to default to line-number for all code blocks
Hey @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.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (10 by maintainers)
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?