Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line numbers on static html files? #672

Open
ghost opened this issue Feb 22, 2017 · 4 comments
Open

line numbers on static html files? #672

ghost opened this issue Feb 22, 2017 · 4 comments
Labels
tag:Upstream Related to an upstream project (e.g., mistune, nbconvert) or notebook example type:Enhancement A proposed extension to the behavior of the project

Comments

@ghost
Copy link

ghost commented Feb 22, 2017

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.

@minrk
Copy link
Member

minrk commented Feb 27, 2017

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.

@ghost
Copy link
Author

ghost commented Feb 27, 2017

Thanks, I'll try this. Shouldn't we also add this as a feature to Jupyter notebooks?

@parente
Copy link
Member

parente commented Jul 10, 2018

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: ipython/ipython#5847 (comment)

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.

@parente parente added type:Enhancement A proposed extension to the behavior of the project tag:Upstream Related to an upstream project (e.g., mistune, nbconvert) or notebook example labels Jul 10, 2018
@pierrepageault
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag:Upstream Related to an upstream project (e.g., mistune, nbconvert) or notebook example type:Enhancement A proposed extension to the behavior of the project
Projects
None yet
Development

No branches or pull requests

3 participants