davidbrochart / nbterm

Jupyter Notebooks in the terminal.
MIT License
756 stars 37 forks source link

Markdown text wrapping cuts off #66

Open jjeffrey opened 2 years ago

jjeffrey commented 2 years ago

When editing a Markdown cell inside nbterm, I can insert line breaks so that the content fits on screen. image

However, when viewing a Markdown cell, text wrapping always cuts off a portion of the text, as long as it overflows. This is independent of the width of the terminal emulator: resizing it does not help.

image

On a related note, Markdown headers, which are center-aligned, are often cut off as well. image

Using Gnome Terminal on Ubuntu 22.04, and Python 3.10.4.

davidbrochart commented 2 years ago

Thanks for reporting @jjeffrey. nbterm relies on Rich for markdown rendering. I don't know if it's possible to configure it so that it wraps text. Do you want to look at it and open a PR? That would be great.

jjeffrey commented 2 years ago

It does seem that euporie, which appears to also use Textualize/rich, has more accurate text wrapping on rendered Markdown cells.

Screenshot from euporie: image

I'm not sure if I'm the best person to look into it, but if I end up tinkering around and figuring out my problem, I'll try to make a PR.

joouha commented 2 years ago

I used rich to render markdown in euporie prior to v1.4.0, but I now use my own renderer based on markdown-it-py (so I can support tables, LaTeX, images, etc. in markdown).

To get rich to wrap the markdown, you'll need to set the max_width on the rich Console when rendering the output here. You can see how this was done in euporie here.