diff --git a/sphinx_gallery/_static/sg_gallery.css b/sphinx_gallery/_static/sg_gallery.css index a06595425..9bcd33c8a 100644 --- a/sphinx_gallery/_static/sg_gallery.css +++ b/sphinx_gallery/_static/sg_gallery.css @@ -178,23 +178,44 @@ thumbnail with its default link Background color */ max-height: 112px; max-width: 160px; } -.sphx-glr-thumbcontainer[tooltip]:hover:after { - background: var(--sg-tooltip-background); + +.sphx-glr-thumbcontainer[tooltip]::before { + content: ""; + position: absolute; + pointer-events: none; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 97; + background-color: var(--sg-tooltip-background); + backdrop-filter: blur(3px); + opacity: 0; + transition: opacity 0.3s; +} + +.sphx-glr-thumbcontainer[tooltip]:hover::before { + opacity: 1; +} + +.sphx-glr-thumbcontainer[tooltip]:hover::after { -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; color: var(--sg-tooltip-foreground); content: attr(tooltip); - padding: 10px; + padding: 10px 10px 5px; z-index: 98; width: 100%; - height: 100%; + max-height: 100%; position: absolute; pointer-events: none; top: 0; box-sizing: border-box; overflow: hidden; - backdrop-filter: blur(3px); + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 6; } .sphx-glr-script-out { diff --git a/sphinx_gallery/gen_rst.py b/sphinx_gallery/gen_rst.py index 3d1d559a4..737afc60e 100644 --- a/sphinx_gallery/gen_rst.py +++ b/sphinx_gallery/gen_rst.py @@ -331,9 +331,6 @@ def extract_intro_and_title(filename, docstring): # Concatenate all lines of the first paragraph and truncate at 95 chars intro = re.sub("\n", " ", intro_paragraph) intro = _sanitize_rst(intro) - if len(intro) > 95: - intro = intro[:95] + "..." - title = _sanitize_rst(title) return intro, title diff --git a/sphinx_gallery/tests/test_gen_rst.py b/sphinx_gallery/tests/test_gen_rst.py index be9932999..a2c56a085 100644 --- a/sphinx_gallery/tests/test_gen_rst.py +++ b/sphinx_gallery/tests/test_gen_rst.py @@ -352,15 +352,14 @@ def test_extract_intro_and_title(): ) # noqa: E501 assert title == '"-`Header"-with:; punct mark\'s' - # Long intro paragraph gets shortened + # Long intro paragraph are preserved intro_paragraph = "\n".join(["this is one line" for _ in range(10)]) intro, _ = sg.extract_intro_and_title( "filename", "Title\n-----\n\n" + intro_paragraph ) assert len(intro_paragraph) > 100 - assert len(intro) < 100 - assert intro.endswith("...") - assert intro_paragraph.replace("\n", " ")[:95] == intro[:95] + assert len(intro) > 100 + assert intro_paragraph.replace("\n", " ") == intro # Errors with pytest.raises(ExtensionError, match="should have a header"):