Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export Jupyter notebook to HTML with line numbers?

If I turn on line numbers in my code cells in a Jupyter Notebook the rendered output when I go to download as HTML does not include the line numbers in the output.

Is there a setting in nbconvert that allows this? (I did not see anything obvious in the nbconvert docs)

If not, is it possible with custom templating in nbconvert?

Why: I want to be able to reference Line numbers from my markdown cells for tutorials.

Ipython 6.1.0 nbconvert 5.3.1 jupyter client 5.1.0

like image 696
Drafter250 Avatar asked Oct 15 '25 09:10

Drafter250


1 Answers

This was solved in this issue of the ipyhton GitHub repository.

Basically nbconvert hasn't got a setting for this, but you can create a custom template to get the result you need.

like image 63
TrinTragula Avatar answered Oct 16 '25 21:10

TrinTragula