line numbers on static html files?
I find it useful to refer to particular segments of code within my Jupyter notebooks as blocks of code can easily stretch to more than 60 lines. Now, the following default option of adding line numbers is very useful.
However, what I would like is for the line numbers to be present in the static html files or PDF files(using pandoc). That way the line number feature is available for people who merely view static versions of my jupyter notebooks.
Is this feature available? If so, I'm not aware of it.
It is not available on nbviewer, but it could be done in your own HTML exports with nbconvert by changing the pygments arguments used to handle code cells. You might have to resort to a custom template to change how pygments is called, if it's not exposed via configuration.
Thanks, I'll try this. Shouldn't we also add this as a feature to Jupyter notebooks?
Shouldn't we also add this as a feature to Jupyter notebooks?
I think the line numbering support in jupyter/notebook cells is a feature of the CodeMirror editor. On nbviewer, no such editor is present so line numbers would need to be added as part of the nbconvert process. Here's an idea from further back: https://github.com/ipython/ipython/issues/5847#issuecomment-57872057
I'd suggest opening an nbconvert ticket (or better: PR) if you'd like to see this possibly make its way to nbviewer, though we'd still have to figure out how to enable or disable it. Whether line numbers are enabled or not for a cell is not part of the ipynb schema at the moment.
It is not available on nbviewer, but it could be done in your own HTML exports with nbconvert by changing the pygments arguments used to handle code cells. You might have to resort to a custom template to change how pygments is called, if it's not exposed via configuration.
I'm quite new to Jupyter and I was'nt able to write such a template. Would you have any example ?