MyST-NB icon indicating copy to clipboard operation
MyST-NB copied to clipboard

Allow cells to have line numbers

Open choldgraf opened this issue 4 years ago • 0 comments

When people use Jupyter Notebook cells, they often want to refer to specific lines as part of explaining something. This would be easier if it were possible to trigger "line numbering" for each code block.

See https://github.com/executablebooks/meta/discussions/343?notification_referrer_id=MDE4Ok5vdGlmaWNhdGlvblRocmVhZDE4NzY3ODU2NTk6MTgzOTY0NQ%3D%3D#discussioncomment-711334 for one example but a few folks have asked about this over time.

I think that one implementation could be to adopt a cell tag like line-numbers. If this tag exists, then when the input is converted to a literal block (somewhere around here?) we could try adding in the line numbers. It seems like this could be as simple as copying what the code-block directive does.

Another option would be to let users define cell-level metadata that exactly matches the metadata one can provide with code-block. Though then it'd be harder for users to do this because the UX around editing cell-level metadata is not great.

choldgraf avatar May 09 '21 14:05 choldgraf