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

Render code cells with line numbers #1580

Closed
carlosnatalino opened this issue Dec 28, 2021 · 4 comments
Closed

Render code cells with line numbers #1580

carlosnatalino opened this issue Dec 28, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@carlosnatalino
Copy link

Description / Summary

It would be nice to enable the rendering of code-cell with the line numbers. This functionality is available in the code-block but these blocks are not run when compiling the book. I looked at the documentation but did not find any way to enable that.

Value / benefit

This would enable the text to easily mention specific lines of code when the code has more than a few lines.

Implementation details

No response

Tasks to complete

No response

@carlosnatalino carlosnatalino added the enhancement New feature or request label Dec 28, 2021
@welcome
Copy link

welcome bot commented Dec 28, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@michaelosthege
Copy link
Contributor

michaelosthege commented Apr 25, 2022

Inspired by readthedocs/sphinx_rtd_theme#1168 this worked for me in both HTML and pdflatex output:

```{code-block} python
---
name: code_linenumbers
linenos: True
caption: |
    This code has line numbers.
---
print("Hello")
print("world.")
```

Duplicate issue #1254

@chrisjsewell
Copy link
Member

This was added in executablebooks/MyST-NB#380, available as nb_number_source_lines globally, and also per notebook or per code cell, see also https://myst-nb.readthedocs.io/en/latest/use/formatting_outputs.html#images-and-figures

@chrisjsewell
Copy link
Member

closing as duplicate

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

No branches or pull requests

3 participants