Skip to content

Conversation

bgmeulem
Copy link

@bgmeulem bgmeulem commented Mar 27, 2025

Currently, long cell output does not scroll. This has been adressed in issues #754 #417 and #372.

These cells are already correctly configured to scroll upon overflow from various parent classes.
The reason these outputs don't scroll vertically is simply because there is no limit on how much vertical space they are allowed to take, so they never overflow.

This PR simply implements a maximum height of 600px for all nboutput container classes, but only for those that contain text. I chose 600px rather arbitrarily, feel free to change to something more dynamic (don't forget to update docs as well then).
Checking if they contain text is done by checking if they have a child with pre. I'm not very accustomed to CSS, so I don't know if this is a good way to check.

I also added an example for this in the docs.

@mgeier
Copy link
Member

mgeier commented Mar 27, 2025

Thanks for this PR!

I'm not sure if an unconditional fixed threshold is the right thing to do, though.

The Jupyter Notebook has already "scrolled" metadata (see #372), so why not use this?

I chose 600px rather arbitrarily

Why not use whatever the Jupyter Notebook uses?

@mgeier
Copy link
Member

mgeier commented Apr 14, 2025

If you want to avoid the (unrelated) CI errors (which I fixed in #835), you can rebase this PR.

@Xmaster6y
Copy link

I personally like this simple solution. Yet it should not be merged.

You can achieve the same using custom CSS:

html_static_path = ["_static"]
html_css_files = [
    "css/nbsphinx.css",
]
/*nbsphinx.css*/
div.nboutput.container div.output_area:has(pre) {
    max-height: 600px;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants