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

Showing line numbers for code blocks #478

Open
PrasadBabarendaGamage opened this issue Jul 11, 2020 · 1 comment
Open

Showing line numbers for code blocks #478

PrasadBabarendaGamage opened this issue Jul 11, 2020 · 1 comment
Labels

Comments

@PrasadBabarendaGamage
Copy link

Hi all, nbsphinx is great!

Just wondering if an nbsphinx option can be added to the sphinx conf to allow nbsphinx to show local line numbers for code blocks? This would make it easier to reference code when writing documentation. In my case, the sphinx documentation is hosted on readthedocs.

Related info:

Setting line numbers in Jupyter notebooks:

Jupyter notebook extension

Jupyter notebook github issues/pull requests related to showing line numbers

The last last link mentions that line numbers can be turned on with the following code. Although, I am unsure of how to use this with nbsphinx.

from notebook.services.config import ConfigManager
c = ConfigManager()
c.update('notebook', {"CodeCell": {"cm_config": {"lineNumbers": True}}})

Thanks

@mgeier
Copy link
Member

mgeier commented Jul 11, 2020

Just wondering if an nbsphinx option can be added to the sphinx conf to allow nbsphinx to show local line numbers for code blocks?

Sure, I'm open for a PR (as long as line numbers are off by default)!

The last last link mentions that line numbers can be turned on with the following code. Although, I am unsure of how to use this with nbsphinx.

This won't help. The line numbers would have to be implemented using Sphinx mechanisms. But since there are already numbered code blocks in Sphinx, it's probably not a big deal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants