From 0bb02d4e71d8d82fc75024ad4cbf9b57a9530c10 Mon Sep 17 00:00:00 2001 From: dkunhamb Date: Wed, 29 Jul 2026 13:59:34 -0500 Subject: [PATCH 01/11] =?UTF-8?q?=E2=9C=A8=20Add=20`link-new-tab`=20option?= =?UTF-8?q?=20to=20card=20directive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sphinx_design/cards.py | 6 ++++++ sphinx_design/extension.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/sphinx_design/cards.py b/sphinx_design/cards.py index ec51cfb8..e04be68a 100644 --- a/sphinx_design/cards.py +++ b/sphinx_design/cards.py @@ -65,6 +65,7 @@ class CardDirective(SdDirective): "link": directives.unchanged_required, "link-type": make_choice(["url", "any", "ref", "doc"]), "link-alt": directives.unchanged, + "link-new-tab": directives.flag, "shadow": make_choice(["none", "sm", "md", "lg"]), "class-card": directives.class_option, "class-header": directives.class_option, @@ -185,6 +186,9 @@ def create_card( # noqa: PLR0915 refuri=link_target, classes=_classes, ) + if "link-new-tab" in options: + link["target"] = "_blank" + link["rel"] = "noreferrer noopener" else: ref_options = { # TODO the presence of classes raises an error if the link cannot be found @@ -200,6 +204,8 @@ def create_card( # noqa: PLR0915 _rawtext, nodes.inline(_rawtext, _rawtext), **ref_options ) inst.set_source_info(link) + if "link-new-tab" in options: + link_container["sd_new_tab"] = True link_container += link container.append(link_container) diff --git a/sphinx_design/extension.py b/sphinx_design/extension.py index 370ddc70..4ef38224 100644 --- a/sphinx_design/extension.py +++ b/sphinx_design/extension.py @@ -56,6 +56,7 @@ def setup_extension(app: Sphinx) -> None: app.connect( "config-inited", partial(setup_custom_directives, directive_map=directive_map) ) + app.connect("doctree-resolved", _resolve_new_tab_refs) @contextmanager @@ -73,6 +74,23 @@ def _add_directive(name, directive, **kwargs): app.add_directive = add_directive # type: ignore[method-assign] +def _resolve_new_tab_refs( + app: Sphinx, doctree: nodes.document, docname: str +) -> None: + """Set ``target`` and ``rel`` on card link references that request a new tab. + + Cross-references are resolved to ``nodes.reference`` during the write + phase, before ``doctree-resolved`` fires, so we can safely walk the tree + here for both URL and internal-link cards. + """ + for container in doctree.findall(PassthroughTextElement): + if not container.get("sd_new_tab"): + continue + for ref in container.findall(nodes.reference): + ref["target"] = "_blank" + ref["rel"] = "noreferrer noopener" + + def add_static_assets(app: Sphinx) -> None: """Register the extension's static assets (HTML-format builders only).""" if app.builder.format != "html": From 97258e3c8c4302a7a51d715c72340d211424111e Mon Sep 17 00:00:00 2001 From: dkunhamb Date: Wed, 29 Jul 2026 14:54:41 -0500 Subject: [PATCH 02/11] =?UTF-8?q?=E2=9C=A8=20Add=20`link-new-tab`=20option?= =?UTF-8?q?=20to=20`grid-item-card`=20directive=20and=20add=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cards.md | 13 +++ docs/snippets/myst/card-link.txt | 8 ++ docs/snippets/rst/card-link.txt | 7 ++ sphinx_design/grids.py | 2 + tests/test_card_link.py | 136 +++++++++++++++++++++++++++++++ 5 files changed, 166 insertions(+) diff --git a/docs/cards.md b/docs/cards.md index 723390c6..ede6d22c 100644 --- a/docs/cards.md +++ b/docs/cards.md @@ -137,6 +137,14 @@ Try hovering over then clicking on the cards below: The entire card can be clicked to navigate to `https://example.com`. ::: +:::{card} Clickable Card (external, new tab) +:link: https://example.com +:link-alt: example.com +:link-new-tab: + +The entire card can be clicked to open `https://example.com` in a new tab. +::: + :::{card} Clickable Card (internal) :link: cards-clickable :link-type: ref @@ -285,6 +293,11 @@ link-type link-alt : Alternative text for the link (that will be used by screen-readers). +link-new-tab +: Flag. When set, the card link opens in a new browser tab + (`target="_blank"`, `rel="noreferrer noopener"`). + Works with all `link-type` values. + shadow : The size of the shadow below the card: `none`, `sm` (default), `md`, `lg`. diff --git a/docs/snippets/myst/card-link.txt b/docs/snippets/myst/card-link.txt index fdd6ff69..ad1eed14 100644 --- a/docs/snippets/myst/card-link.txt +++ b/docs/snippets/myst/card-link.txt @@ -17,6 +17,14 @@ The entire card can be clicked to navigate to . The entire card can be clicked to navigate to . ::: +:::{card} Clickable Card (external, new tab) +:link: https://example.com +:link-alt: example.com +:link-new-tab: + +The entire card can be clicked to open in a new tab. +::: + :::{card} Clickable Card (internal) :link: cards-clickable :link-type: ref diff --git a/docs/snippets/rst/card-link.txt b/docs/snippets/rst/card-link.txt index e721db06..d1c5a4d7 100644 --- a/docs/snippets/rst/card-link.txt +++ b/docs/snippets/rst/card-link.txt @@ -16,6 +16,13 @@ Using the ``link`` and ``link-type`` options, you can turn an entire card into a The entire card can be clicked to navigate to https://example.com. +.. card:: Clickable Card (external, new tab) + :link: https://example.com + :link-alt: example.com + :link-new-tab: + + The entire card can be clicked to open https://example.com in a new tab. + .. card:: Clickable Card (internal) :link: cards-clickable :link-type: ref diff --git a/sphinx_design/grids.py b/sphinx_design/grids.py index c0325c0c..7ceb7555 100644 --- a/sphinx_design/grids.py +++ b/sphinx_design/grids.py @@ -228,6 +228,7 @@ class GridItemCardDirective(SdDirective): "link": directives.unchanged_required, "link-type": make_choice(["url", "any", "ref", "doc"]), "link-alt": directives.unchanged, + "link-new-tab": directives.flag, "shadow": make_choice(["none", "sm", "md", "lg"]), "class-card": directives.class_option, "class-body": directives.class_option, @@ -271,6 +272,7 @@ def run_with_defaults(self) -> list[nodes.Node]: "link", "link-type", "link-alt", + "link-new-tab", "shadow", "class-card", "class-body", diff --git a/tests/test_card_link.py b/tests/test_card_link.py index b4cce89f..7a7e1b99 100644 --- a/tests/test_card_link.py +++ b/tests/test_card_link.py @@ -273,3 +273,139 @@ def test_card_ref_unresolved_warns(sphinx_builder): # build completed and the content survives, just without a resolved link assert "Card body" in html assert _stretched_link_hrefs(html) == [] + + +# --------------------------------------------------------------------------- +# link-new-tab tests +# --------------------------------------------------------------------------- + +NEW_TAB_URL_RST = """ +Heading +======= + +.. card:: New-tab URL card + :link: https://example.com + :link-new-tab: + + Card body +""" + +NEW_TAB_URL_MYST = """ +# Heading + +:::{card} New-tab URL card +:link: https://example.com +:link-new-tab: + +Card body +::: +""" + + +@pytest.mark.parametrize("fmt", ["rst", MYST_PARAM]) +def test_card_url_new_tab(fmt, sphinx_builder): + """``link-new-tab`` adds ``target="_blank"`` and ``rel="noreferrer noopener"`` + to a URL card link. + """ + builder = _build(sphinx_builder, fmt, NEW_TAB_URL_RST, NEW_TAB_URL_MYST) + html = (builder.out_path / "index.html").read_text(encoding="utf8") + assert _stretched_link_hrefs(html) == ["https://example.com"] + assert re.search( + r']*sd-stretched-link[^>]*target="_blank"', html + ), "target=_blank not found on stretched-link anchor" + assert re.search( + r']*sd-stretched-link[^>]*rel="noreferrer noopener"', html + ), "rel=noreferrer noopener not found on stretched-link anchor" + + +NEW_TAB_REF_RST = """ +Heading +======= + +My Section +---------- + +Some content. + +.. card:: New-tab internal card + :link: my section + :link-type: ref + :link-new-tab: + + Card body +""" + +NEW_TAB_REF_MYST = """ +# Heading + +## My Section + +Some content. + +:::{card} New-tab internal card +:link: my section +:link-type: ref +:link-new-tab: + +Card body +::: +""" + + +@pytest.mark.parametrize("fmt", ["rst", MYST_PARAM]) +def test_card_ref_new_tab(fmt, sphinx_builder): + """``link-new-tab`` also applies to internal cross-reference cards. + + ``pending_xref`` is resolved to ``nodes.reference`` before + ``doctree-resolved`` fires, so the event handler can stamp the + ``target`` and ``rel`` attributes onto the real anchor. + """ + builder = _build(sphinx_builder, fmt, NEW_TAB_REF_RST, NEW_TAB_REF_MYST) + html = (builder.out_path / "index.html").read_text(encoding="utf8") + assert "#my-section" in _stretched_link_hrefs(html) + assert re.search( + r']*sd-stretched-link[^>]*target="_blank"', html + ), "target=_blank not found on resolved ref anchor" + assert re.search( + r']*sd-stretched-link[^>]*rel="noreferrer noopener"', html + ), "rel=noreferrer noopener not found on resolved ref anchor" + + +NEW_TAB_GRID_RST = """ +Heading +======= + +.. grid:: 1 + + .. grid-item-card:: New-tab grid card + :link: https://example.com + :link-new-tab: + + Grid card body +""" + +NEW_TAB_GRID_MYST = """ +# Heading + +::::{grid} 1 + +:::{grid-item-card} New-tab grid card +:link: https://example.com +:link-new-tab: + +Grid card body +::: + +:::: +""" + + +@pytest.mark.parametrize("fmt", ["rst", MYST_PARAM]) +def test_grid_item_card_new_tab(fmt, sphinx_builder): + """``link-new-tab`` works on ``grid-item-card`` (synced ``option_spec``).""" + builder = _build(sphinx_builder, fmt, NEW_TAB_GRID_RST, NEW_TAB_GRID_MYST) + html = (builder.out_path / "index.html").read_text(encoding="utf8") + assert _stretched_link_hrefs(html) == ["https://example.com"] + assert re.search( + r']*sd-stretched-link[^>]*target="_blank"', html + ), "target=_blank not found on grid-item-card stretched-link anchor" From 177ed677557ceb3ef4cee31da1898799f8a1bc6c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 Jul 2026 19:58:43 +0000 Subject: [PATCH 03/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sphinx_design/extension.py | 4 +--- tests/test_card_link.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sphinx_design/extension.py b/sphinx_design/extension.py index 4ef38224..a3044f9d 100644 --- a/sphinx_design/extension.py +++ b/sphinx_design/extension.py @@ -74,9 +74,7 @@ def _add_directive(name, directive, **kwargs): app.add_directive = add_directive # type: ignore[method-assign] -def _resolve_new_tab_refs( - app: Sphinx, doctree: nodes.document, docname: str -) -> None: +def _resolve_new_tab_refs(app: Sphinx, doctree: nodes.document, docname: str) -> None: """Set ``target`` and ``rel`` on card link references that request a new tab. Cross-references are resolved to ``nodes.reference`` during the write diff --git a/tests/test_card_link.py b/tests/test_card_link.py index 7a7e1b99..116a5044 100644 --- a/tests/test_card_link.py +++ b/tests/test_card_link.py @@ -310,9 +310,9 @@ def test_card_url_new_tab(fmt, sphinx_builder): builder = _build(sphinx_builder, fmt, NEW_TAB_URL_RST, NEW_TAB_URL_MYST) html = (builder.out_path / "index.html").read_text(encoding="utf8") assert _stretched_link_hrefs(html) == ["https://example.com"] - assert re.search( - r']*sd-stretched-link[^>]*target="_blank"', html - ), "target=_blank not found on stretched-link anchor" + assert re.search(r']*sd-stretched-link[^>]*target="_blank"', html), ( + "target=_blank not found on stretched-link anchor" + ) assert re.search( r']*sd-stretched-link[^>]*rel="noreferrer noopener"', html ), "rel=noreferrer noopener not found on stretched-link anchor" @@ -363,9 +363,9 @@ def test_card_ref_new_tab(fmt, sphinx_builder): builder = _build(sphinx_builder, fmt, NEW_TAB_REF_RST, NEW_TAB_REF_MYST) html = (builder.out_path / "index.html").read_text(encoding="utf8") assert "#my-section" in _stretched_link_hrefs(html) - assert re.search( - r']*sd-stretched-link[^>]*target="_blank"', html - ), "target=_blank not found on resolved ref anchor" + assert re.search(r']*sd-stretched-link[^>]*target="_blank"', html), ( + "target=_blank not found on resolved ref anchor" + ) assert re.search( r']*sd-stretched-link[^>]*rel="noreferrer noopener"', html ), "rel=noreferrer noopener not found on resolved ref anchor" @@ -406,6 +406,6 @@ def test_grid_item_card_new_tab(fmt, sphinx_builder): builder = _build(sphinx_builder, fmt, NEW_TAB_GRID_RST, NEW_TAB_GRID_MYST) html = (builder.out_path / "index.html").read_text(encoding="utf8") assert _stretched_link_hrefs(html) == ["https://example.com"] - assert re.search( - r']*sd-stretched-link[^>]*target="_blank"', html - ), "target=_blank not found on grid-item-card stretched-link anchor" + assert re.search(r']*sd-stretched-link[^>]*target="_blank"', html), ( + "target=_blank not found on grid-item-card stretched-link anchor" + ) From b5a3120fef884cc5b20f0f7870ea75d4c491e82b Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 9 Nov 2026 20:34:23 +0100 Subject: [PATCH 04/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20REFACTOR:=20split=20?= =?UTF-8?q?the=20card=20link=20builder=20out=20of=20create=5Fcard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moves the `link` block of `CardDirective.create_card` into `CardDirective._create_link`, which fixes ruff's PLR0912 (too many branches) and makes the `# noqa: PLR0915` unnecessary. Also drops the parse-time `target`/`rel` on URL links: the `doctree-resolved` handler already sets them for every link type, so it is now the single mechanism. --- sphinx_design/cards.py | 86 +++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/sphinx_design/cards.py b/sphinx_design/cards.py index e04be68a..eede2cac 100644 --- a/sphinx_design/cards.py +++ b/sphinx_design/cards.py @@ -80,7 +80,7 @@ def run_with_defaults(self) -> list[nodes.Node]: return [self.create_card(self, self.arguments, self.options)] @classmethod - def create_card( # noqa: PLR0915 + def create_card( cls, inst: SphinxDirective, arguments: list | None, options: dict ) -> nodes.Node: """Run the directive.""" @@ -171,46 +171,56 @@ def create_card( # noqa: PLR0915 container.append(image_bottom) if "link" in options: - link_container = PassthroughTextElement() - _classes = ["sd-stretched-link", "sd-hide-link-text"] - link_type = options.get("link-type", "url") - # the raw (un-normalised) target, kept for user-visible fallback text - link_raw = options["link"] - link_target = cls.get_link_target(link_raw, link_type) - _rawtext = options.get("link-alt") or link_raw - if link_type == "url": - link = nodes.reference( - _rawtext, - "", - nodes.inline(_rawtext, _rawtext), - refuri=link_target, - classes=_classes, - ) - if "link-new-tab" in options: - link["target"] = "_blank" - link["rel"] = "noreferrer noopener" - else: - ref_options = { - # TODO the presence of classes raises an error if the link cannot be found - "classes": _classes, - "reftarget": link_target, - "refdoc": inst.env.docname, - "refdomain": "" if link_type == "any" else "std", - "reftype": link_type, - "refexplicit": "link-alt" in options, - "refwarn": True, - } - link = addnodes.pending_xref( - _rawtext, nodes.inline(_rawtext, _rawtext), **ref_options - ) - inst.set_source_info(link) - if "link-new-tab" in options: - link_container["sd_new_tab"] = True - link_container += link - container.append(link_container) + container.append(cls._create_link(inst, options)) return card + @classmethod + def _create_link( + cls, inst: SphinxDirective, options: dict + ) -> PassthroughTextElement: + """Create the stretched link that makes the whole card clickable. + + With ``link-new-tab``, the container is marked ``sd_new_tab``; + the ``doctree-resolved`` handler then sets ``target``/``rel`` + on the reference, once any cross-reference has been resolved. + """ + link_container = PassthroughTextElement() + _classes = ["sd-stretched-link", "sd-hide-link-text"] + link_type = options.get("link-type", "url") + # the raw (un-normalised) target, kept for user-visible fallback text + link_raw = options["link"] + link_target = cls.get_link_target(link_raw, link_type) + _rawtext = options.get("link-alt") or link_raw + link: nodes.Element + if link_type == "url": + link = nodes.reference( + _rawtext, + "", + nodes.inline(_rawtext, _rawtext), + refuri=link_target, + classes=_classes, + ) + else: + ref_options = { + # TODO the presence of classes raises an error if the link cannot be found + "classes": _classes, + "reftarget": link_target, + "refdoc": inst.env.docname, + "refdomain": "" if link_type == "any" else "std", + "reftype": link_type, + "refexplicit": "link-alt" in options, + "refwarn": True, + } + link = addnodes.pending_xref( + _rawtext, nodes.inline(_rawtext, _rawtext), **ref_options + ) + inst.set_source_info(link) + if "link-new-tab" in options: + link_container["sd_new_tab"] = True + link_container += link + return link_container + @staticmethod def get_link_target(target: str, link_type: str) -> str: """Normalise a ``link`` option value into a reference target. From 7f9b364cf9d001c7dbf41278b54ac10919fdc19c Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 9 Nov 2026 20:35:04 +0100 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=A7=AA=20TEST:=20regenerate=20the?= =?UTF-8?q?=20card-link=20snippet=20fixtures=20for=20link-new-tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Registers `sd_new_tab` with the test XML normalizer's boolean attributes, so the fixtures read `sd_new_tab="True"` on every docutils version (docutils 0.22 serializes it as "1"), and regenerates `snippet_{pre,post}_card-link.xml` for the new snippet card. --- sphinx_design/testing.py | 1 + tests/test_snippets/snippet_post_card-link.xml | 14 ++++++++++++++ tests/test_snippets/snippet_pre_card-link.xml | 14 ++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/sphinx_design/testing.py b/sphinx_design/testing.py index 47d33b31..791c65f0 100644 --- a/sphinx_design/testing.py +++ b/sphinx_design/testing.py @@ -57,6 +57,7 @@ "opened", "refexplicit", "refwarn", + "sd_new_tab", "selected", "translatable", "translated", diff --git a/tests/test_snippets/snippet_post_card-link.xml b/tests/test_snippets/snippet_post_card-link.xml index 59ec5e47..63ff2f87 100644 --- a/tests/test_snippets/snippet_post_card-link.xml +++ b/tests/test_snippets/snippet_post_card-link.xml @@ -42,6 +42,20 @@ example.com + + + + + Clickable Card (external, new tab) + + The entire card can be clicked to open + + https://example.com + in a new tab. + + + + example.com diff --git a/tests/test_snippets/snippet_pre_card-link.xml b/tests/test_snippets/snippet_pre_card-link.xml index 2f7b35bf..fd581955 100644 --- a/tests/test_snippets/snippet_pre_card-link.xml +++ b/tests/test_snippets/snippet_pre_card-link.xml @@ -42,6 +42,20 @@ example.com + + + + + Clickable Card (external, new tab) + + The entire card can be clicked to open + + https://example.com + in a new tab. + + + + example.com From 8d2ddfbae59bfd1a7dca2f4f2b5ac5bca4fad31a Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 9 Nov 2026 20:36:20 +0100 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=A7=AA=20TEST:=20pin=20down=20link-?= =?UTF-8?q?new-tab=20on=20every=20link=20type=20and=20Sphinx=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - assert `target`/`rel` on the card's own stretched link tag, including the `rel` assertion the grid-item-card test lacked; - `rel` is only rendered by Sphinx >= 7.4, so assert it is absent below that (the declared floor is 7.2); - add a `link-type: doc` card; - add a negative test: URL and ref cards without the flag get neither `target` nor `rel`. --- tests/test_card_link.py | 126 +++++++++++++++++++++++++++++++++++----- 1 file changed, 110 insertions(+), 16 deletions(-) diff --git a/tests/test_card_link.py b/tests/test_card_link.py index 116a5044..805348f3 100644 --- a/tests/test_card_link.py +++ b/tests/test_card_link.py @@ -16,6 +16,7 @@ from docutils.parsers.rst import directives import pytest +import sphinx from sphinx_design.cards import CardDirective @@ -279,6 +280,28 @@ def test_card_ref_unresolved_warns(sphinx_builder): # link-new-tab tests # --------------------------------------------------------------------------- +# Sphinx's HTML writer renders a reference's ``rel`` attribute only from 7.4; +# ``target`` is rendered on every supported version. +# Browsers imply ``noopener`` for ``target="_blank"`` anyway. +RENDERS_REL = sphinx.version_info >= (7, 4) + + +def _stretched_link_tags(html): + """Return the opening ```` tag of every card ``sd-stretched-link``.""" + return re.findall(r"]*\bsd-stretched-link\b[^>]*>", html) + + +def _assert_opens_in_new_tab(html): + """The card's only stretched link opens in a new tab.""" + tags = _stretched_link_tags(html) + assert len(tags) == 1, tags + assert 'target="_blank"' in tags[0], tags[0] + if RENDERS_REL: + assert 'rel="noreferrer noopener"' in tags[0], tags[0] + else: + assert "rel=" not in tags[0], tags[0] + + NEW_TAB_URL_RST = """ Heading ======= @@ -310,12 +333,7 @@ def test_card_url_new_tab(fmt, sphinx_builder): builder = _build(sphinx_builder, fmt, NEW_TAB_URL_RST, NEW_TAB_URL_MYST) html = (builder.out_path / "index.html").read_text(encoding="utf8") assert _stretched_link_hrefs(html) == ["https://example.com"] - assert re.search(r']*sd-stretched-link[^>]*target="_blank"', html), ( - "target=_blank not found on stretched-link anchor" - ) - assert re.search( - r']*sd-stretched-link[^>]*rel="noreferrer noopener"', html - ), "rel=noreferrer noopener not found on stretched-link anchor" + _assert_opens_in_new_tab(html) NEW_TAB_REF_RST = """ @@ -362,13 +380,41 @@ def test_card_ref_new_tab(fmt, sphinx_builder): """ builder = _build(sphinx_builder, fmt, NEW_TAB_REF_RST, NEW_TAB_REF_MYST) html = (builder.out_path / "index.html").read_text(encoding="utf8") - assert "#my-section" in _stretched_link_hrefs(html) - assert re.search(r']*sd-stretched-link[^>]*target="_blank"', html), ( - "target=_blank not found on resolved ref anchor" - ) - assert re.search( - r']*sd-stretched-link[^>]*rel="noreferrer noopener"', html - ), "rel=noreferrer noopener not found on resolved ref anchor" + assert _stretched_link_hrefs(html) == ["#my-section"] + _assert_opens_in_new_tab(html) + + +@pytest.mark.parametrize("fmt", ["rst", MYST_PARAM]) +def test_card_doc_new_tab(fmt, sphinx_builder): + """``link-new-tab`` applies to a ``link-type: doc`` card linking to another page.""" + if fmt == "rst": + builder = sphinx_builder(conf_kwargs={"extensions": ["sphinx_design"]}) + index = ( + "Heading\n=======\n\n" + ".. toctree::\n\n other\n\n" + ".. card:: New-tab doc card\n" + " :link: other\n :link-type: doc\n :link-new-tab:\n\n" + " Card body\n" + ) + builder.src_path.joinpath("index.rst").write_text(index, encoding="utf8") + builder.src_path.joinpath("other.rst").write_text( + "Other\n=====\n", encoding="utf8" + ) + else: + builder = sphinx_builder() + index = ( + "# Heading\n\n" + "```{toctree}\nother\n```\n\n" + ":::{card} New-tab doc card\n" + ":link: other\n:link-type: doc\n:link-new-tab:\n\n" + "Card body\n:::\n" + ) + builder.src_path.joinpath("index.md").write_text(index, encoding="utf8") + builder.src_path.joinpath("other.md").write_text("# Other\n", encoding="utf8") + builder.build() + html = (builder.out_path / "index.html").read_text(encoding="utf8") + assert _stretched_link_hrefs(html) == ["other.html"] + _assert_opens_in_new_tab(html) NEW_TAB_GRID_RST = """ @@ -406,6 +452,54 @@ def test_grid_item_card_new_tab(fmt, sphinx_builder): builder = _build(sphinx_builder, fmt, NEW_TAB_GRID_RST, NEW_TAB_GRID_MYST) html = (builder.out_path / "index.html").read_text(encoding="utf8") assert _stretched_link_hrefs(html) == ["https://example.com"] - assert re.search(r']*sd-stretched-link[^>]*target="_blank"', html), ( - "target=_blank not found on grid-item-card stretched-link anchor" - ) + _assert_opens_in_new_tab(html) + + +NO_NEW_TAB_RST = """ +Heading +======= + +My Section +---------- + +.. card:: URL card + :link: https://example.com + + Card body + +.. card:: Internal card + :link: my section + :link-type: ref + + Card body +""" + +NO_NEW_TAB_MYST = """ +# Heading + +## My Section + +:::{card} URL card +:link: https://example.com + +Card body +::: + +:::{card} Internal card +:link: my section +:link-type: ref + +Card body +::: +""" + + +@pytest.mark.parametrize("fmt", ["rst", MYST_PARAM]) +def test_card_link_without_new_tab(fmt, sphinx_builder): + """Without ``link-new-tab``, card links keep opening in the same tab.""" + builder = _build(sphinx_builder, fmt, NO_NEW_TAB_RST, NO_NEW_TAB_MYST) + html = (builder.out_path / "index.html").read_text(encoding="utf8") + assert _stretched_link_hrefs(html) == ["https://example.com", "#my-section"] + for tag in _stretched_link_tags(html): + assert "target=" not in tag, tag + assert "rel=" not in tag, tag From 70c1e9d44291beaffc53e968c02cca3bc20b2a2e Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 9 Nov 2026 20:37:51 +0100 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=93=9A=20DOCS:=20note=20that=20Sphi?= =?UTF-8?q?nx=20renders=20the=20link-new-tab=20rel=20only=20from=207.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cards.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/cards.md b/docs/cards.md index ede6d22c..8a39e94a 100644 --- a/docs/cards.md +++ b/docs/cards.md @@ -297,6 +297,8 @@ link-new-tab : Flag. When set, the card link opens in a new browser tab (`target="_blank"`, `rel="noreferrer noopener"`). Works with all `link-type` values. + Sphinx renders the `rel` attribute only from version 7.4; + browsers already treat `target="_blank"` links as `noopener`. shadow : The size of the shadow below the card: `none`, `sm` (default), `md`, `lg`. From f4f26c38b450dcadd4ccbeeae734ee89ba01da0b Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 9 Nov 2026 21:38:42 +0100 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=93=9A=20DOCS:=20note=20that=20link?= =?UTF-8?q?-new-tab=20has=20no=20effect=20without=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cards.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cards.md b/docs/cards.md index 8a39e94a..ebc65783 100644 --- a/docs/cards.md +++ b/docs/cards.md @@ -296,7 +296,7 @@ link-alt link-new-tab : Flag. When set, the card link opens in a new browser tab (`target="_blank"`, `rel="noreferrer noopener"`). - Works with all `link-type` values. + Works with all `link-type` values; has no effect without `link`. Sphinx renders the `rel` attribute only from version 7.4; browsers already treat `target="_blank"` links as `noopener`. From a81933019a26a5ce1e5e5871d645dc51630e619d Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 9 Nov 2026 23:13:11 +0100 Subject: [PATCH 09/11] =?UTF-8?q?=E2=9C=A8=20NEW:=20add=20a=20new-tab=20fl?= =?UTF-8?q?ag=20to=20button-link=20and=20button-ref?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new-tab handler now acts on any element marked sd_new_tab, not only the card's link container, and the button directives mark their paragraph container when new-tab is set. This resolves the "TODO open in new tab" in _ButtonDirective.run_with_defaults. The marker sits on the container because a button-ref is a pending_xref, replaced on resolution, so target and rel are set on the resolved reference. Tests cover both button kinds (including button-ref with rich content and with expand / click-parent), buttons and links without the flag, the LaTeX and text builders, and the handler on a hand-built doctree. The button docs describe the option, and both option entries now say it has no effect outside HTML and suggest telling readers about the new tab. --- docs/badges_buttons.md | 36 ++++++ docs/cards.md | 4 + sphinx_design/badges_buttons.py | 8 +- sphinx_design/extension.py | 17 ++- tests/test_buttons.py | 217 ++++++++++++++++++++++++++++++++ 5 files changed, 276 insertions(+), 6 deletions(-) diff --git a/docs/badges_buttons.md b/docs/badges_buttons.md index 594746c6..4f607928 100644 --- a/docs/badges_buttons.md +++ b/docs/badges_buttons.md @@ -228,6 +228,35 @@ Use the `click-parent` option to make the button's parent container also clickab ::: +Use the `new-tab` option to open the button's link in a new browser tab. +Since this changes what the reader expects a link to do, +say so in the button text: + +```{button-link} https://example.com +:color: primary +:new-tab: + +example.com (opens in a new tab) +``` + +````{tab-set-code} +```markdown +:::{button-link} https://example.com +:color: primary +:new-tab: + +example.com (opens in a new tab) +::: +``` +```rst +.. button-link:: https://example.com + :color: primary + :new-tab: + + example.com (opens in a new tab) +``` +```` + ### `button-link` and `button-ref` options ref-type (`button-ref` only) @@ -249,6 +278,13 @@ expand click-parent : Make parent container also clickable +new-tab +: Open the link in a new browser tab (`target="_blank"`, `rel="noreferrer noopener"`). + Works for both `button-link` and `button-ref`. + Sphinx renders the `rel` attribute only from version 7.4; + browsers already treat `target="_blank"` links as `noopener`. + It has no effect on output formats other than HTML. + tooltip : Add tooltip on hover diff --git a/docs/cards.md b/docs/cards.md index ebc65783..f8a5c251 100644 --- a/docs/cards.md +++ b/docs/cards.md @@ -299,6 +299,10 @@ link-new-tab Works with all `link-type` values; has no effect without `link`. Sphinx renders the `rel` attribute only from version 7.4; browsers already treat `target="_blank"` links as `noopener`. + It has no effect on output formats other than HTML. + Tell readers the link opens a new tab, for example in `link-alt`. + To open every external link in a new tab, site-wide, + see the [sphinx-new-tab-link](https://pypi.org/project/sphinx-new-tab-link/) extension. shadow : The size of the shadow below the card: `none`, `sm` (default), `md`, `lg`. diff --git a/sphinx_design/badges_buttons.py b/sphinx_design/badges_buttons.py index 1b743d49..0815a1f0 100644 --- a/sphinx_design/badges_buttons.py +++ b/sphinx_design/badges_buttons.py @@ -466,6 +466,8 @@ class _ButtonDirective(SdDirective): "expand": directives.flag, # make parent also clickable "click-parent": directives.flag, + # open the link in a new browser tab + "new-tab": directives.flag, "tooltip": directives.unchanged_required, "shadow": directives.flag, # ref button only @@ -527,7 +529,6 @@ def run_with_defaults(self) -> list[nodes.Node]: if "class" in self.options: classes.extend(self.options["class"]) node = self.create_ref_node(rawtext, target, bool(self.content), classes) - # TODO open in new tab self.set_source_info(node) if "tooltip" in self.options: # ``reftitle`` is rendered as the HTML ``title`` attribute, whose @@ -554,6 +555,11 @@ def run_with_defaults(self) -> list[nodes.Node]: container = nodes.paragraph( classes=self.options.get("align", []), translatable=False ) + if "new-tab" in self.options: + # the reference itself may be a ``pending_xref``, replaced on + # resolution, so mark the container: ``target``/``rel`` are set on + # the resolved reference by the ``doctree-resolved`` handler + container["sd_new_tab"] = True self.set_source_info(container) container += node diff --git a/sphinx_design/extension.py b/sphinx_design/extension.py index a3044f9d..63ab163d 100644 --- a/sphinx_design/extension.py +++ b/sphinx_design/extension.py @@ -74,16 +74,23 @@ def _add_directive(name, directive, **kwargs): app.add_directive = add_directive # type: ignore[method-assign] +def _has_new_tab_marker(node: nodes.Node) -> bool: + """Return whether ``node`` is an element marked to open its links in a new tab.""" + return isinstance(node, nodes.Element) and bool(node.get("sd_new_tab")) + + def _resolve_new_tab_refs(app: Sphinx, doctree: nodes.document, docname: str) -> None: - """Set ``target`` and ``rel`` on card link references that request a new tab. + """Set ``target`` and ``rel`` on the link references that request a new tab. + A component that opens in a new tab (a card with ``link-new-tab``, + a button with ``new-tab``) marks the element containing its reference + with ``sd_new_tab``. Cross-references are resolved to ``nodes.reference`` during the write phase, before ``doctree-resolved`` fires, so we can safely walk the tree - here for both URL and internal-link cards. + here for both URL and internal links. + Writers other than HTML ignore both attributes. """ - for container in doctree.findall(PassthroughTextElement): - if not container.get("sd_new_tab"): - continue + for container in doctree.findall(_has_new_tab_marker): for ref in container.findall(nodes.reference): ref["target"] = "_blank" ref["rel"] = "noreferrer noopener" diff --git a/tests/test_buttons.py b/tests/test_buttons.py index d0b38353..3b928ddb 100644 --- a/tests/test_buttons.py +++ b/tests/test_buttons.py @@ -12,6 +12,8 @@ warning and still build (no traceback). * #156 - a button whose RST content is a line block renders its lines as separate lines, rather than keeping the literal ``|`` markers. +* #170 - the ``new-tab`` flag opens the link of either button in a new tab, + in HTML only. """ import re @@ -19,13 +21,18 @@ from babel.messages.catalog import Catalog from babel.messages.mofile import write_mo from docutils import nodes +from docutils.frontend import get_default_settings +from docutils.parsers.rst import Parser +from docutils.utils import new_document import pytest +import sphinx from sphinx_design.badges_buttons import ( _BUTTON_REF_MARKER_PREFIX, ButtonLinkDirective, ButtonRefDirective, ) +from sphinx_design.extension import _resolve_new_tab_refs from sphinx_design.icons import sd_icon try: @@ -610,3 +617,213 @@ def test_button_link_line_block_translated(sphinx_builder): builder.build() html = (builder.out_path / "index.html").read_text(encoding="utf8") assert _button_texts(html) == ["hallo
neue Zeile"] + + +# --------------------------------------------------------------------------- +# new-tab tests (#170) +# --------------------------------------------------------------------------- + +# Sphinx's HTML writer renders a reference's ``rel`` attribute only from 7.4; +# ``target`` is rendered on every supported version. +RENDERS_REL = sphinx.version_info >= (7, 4) + +_BUTTON_TAG_RE = re.compile(r'
]*class="[^"]*\bsd-btn\b[^"]*"[^>]*>') + + +def _button_tags(html: str) -> list[str]: + """Return the opening ```` tag of every button.""" + return _BUTTON_TAG_RE.findall(html) + + +def _opens_in_new_tab(tag: str) -> bool: + """Return whether a button's opening tag opens its link in a new tab. + + The ``rel`` value is checked exactly where Sphinx renders it, + and checked absent where it does not. + """ + rel_ok = 'rel="noreferrer noopener"' in tag if RENDERS_REL else "rel=" not in tag + return 'target="_blank"' in tag and rel_ok + + +NEW_TAB = { + "rst": """ +Heading +======= + +.. _target-section: + +Target Section +-------------- + +.. button-link:: https://example.com + :new-tab: + + Link new tab + +.. button-ref:: target-section + :ref-type: ref + :new-tab: + + Ref *new* tab + +.. button-ref:: target-section + :new-tab: + :expand: + :click-parent: + +.. button-link:: https://example.org + + Link same tab + +.. button-ref:: target-section + :ref-type: ref + + Ref same tab + +A plain https://example.net link. +""", + "myst": """ +# Heading + +(target-section)= + +## Target Section + +```{button-link} https://example.com +:new-tab: + +Link new tab +``` + +```{button-ref} target-section +:ref-type: ref +:new-tab: + +Ref *new* tab +``` + +```{button-ref} target-section +:new-tab: +:expand: +:click-parent: +``` + +```{button-link} https://example.org +Link same tab +``` + +```{button-ref} target-section +:ref-type: ref + +Ref same tab +``` + +A plain link. +""", +} + + +@pytest.mark.parametrize("fmt", ["rst", MYST_PARAM]) +def test_button_new_tab(fmt, sphinx_builder): + """``new-tab`` opens a ``button-link`` or ``button-ref`` in a new tab. + + The ``button-ref`` is a ``pending_xref`` that resolution replaces + (and whose rich content the stash/graft post-transforms restore), + so the marker sits on the button's container, and the attributes are + set on the resolved reference; ``expand`` wraps the reference in one + more element, which must not hide it. + Buttons without the flag, and other links, are left alone. + """ + builder = _build(sphinx_builder, fmt, NEW_TAB["rst"], NEW_TAB["myst"]) + html = (builder.out_path / "index.html").read_text(encoding="utf8") + tags = _button_tags(html) + assert len(tags) == 5, tags + hrefs = [re.search(r'href="([^"]*)"', tag).group(1) for tag in tags] + assert hrefs == [ + "https://example.com", + "#target-section", + "#target-section", + "https://example.org", + "#target-section", + ] + assert [_opens_in_new_tab(tag) for tag in tags] == [True, True, True, False, False] + for tag in tags[3:]: + assert "target=" not in tag, tag + assert "rel=" not in tag, tag + # the rich content of the new-tab ``button-ref`` survives resolution + assert "new" in html + # the plain link outside any button is untouched + [plain] = re.findall(r']*href="https://example.net"[^>]*>', html) + assert "target=" not in plain, plain + # the marker itself never reaches the output + assert "sd_new_tab" not in html + + +NEW_TAB_NON_HTML_RST = """ +Heading +======= + +.. _target-section: + +Target Section +-------------- + +.. button-link:: https://example.com + :new-tab: + + Link new tab + +.. button-ref:: target-section + :ref-type: ref + :new-tab: + + Ref new tab + +.. card:: Card new tab + :link: https://example.org + :link-new-tab: + + Card body +""" + + +@pytest.mark.parametrize( + ("buildername", "pattern"), [("latex", "*.tex"), ("text", "index.txt")] +) +def test_new_tab_non_html(buildername, pattern, sphinx_builder): + """``new-tab`` / ``link-new-tab`` build without warnings for other formats, + which do not render ``target`` or ``rel``. + """ + builder = _build_rst(sphinx_builder, NEW_TAB_NON_HTML_RST, buildername) + [output] = builder.out_path.glob(pattern) + text = output.read_text(encoding="utf8") + assert "Link new tab" in text + assert "_blank" not in text + assert "noreferrer" not in text + if buildername == "latex": + assert r"\sphinxhref{https://example.com}{Link new tab}" in text + + +def _new_tab_doctree() -> nodes.document: + """Return a document with one reference in each kind of container.""" + document = new_document("test", get_default_settings(Parser)) + for marked in (True, False): + paragraph = nodes.paragraph() + if marked: + paragraph["sd_new_tab"] = True + paragraph += nodes.inline("", "", nodes.reference("", "x", refuri="a")) + document += paragraph + return document + + +def test_resolve_new_tab_refs_any_marked_element(): + """The handler sets ``target``/``rel`` inside any marked element, + including on nested references, and nowhere else. + """ + document = _new_tab_doctree() + _resolve_new_tab_refs(None, document, "test") + marked, unmarked = document.findall(nodes.reference) + assert marked["target"] == "_blank" + assert marked["rel"] == "noreferrer noopener" + assert "target" not in unmarked + assert "rel" not in unmarked From 7cc2507a38256816127a3b2327a04ea68d7b2f36 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 10 Nov 2026 00:17:02 +0100 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20keep=20an=20aut?= =?UTF-8?q?hored=20target=20on=20links=20in=20a=20new-tab=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The doctree-resolved handler now leaves a reference that already has a target untouched, such as a link with its own attributes nested in a button's text, instead of overwriting its target and rel. --- sphinx_design/extension.py | 4 ++++ tests/test_buttons.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/sphinx_design/extension.py b/sphinx_design/extension.py index 63ab163d..45e2154b 100644 --- a/sphinx_design/extension.py +++ b/sphinx_design/extension.py @@ -88,10 +88,14 @@ def _resolve_new_tab_refs(app: Sphinx, doctree: nodes.document, docname: str) -> Cross-references are resolved to ``nodes.reference`` during the write phase, before ``doctree-resolved`` fires, so we can safely walk the tree here for both URL and internal links. + A reference that already has a ``target`` (for example a link nested in + a button's text, given its own attributes) is left as authored. Writers other than HTML ignore both attributes. """ for container in doctree.findall(_has_new_tab_marker): for ref in container.findall(nodes.reference): + if "target" in ref: + continue ref["target"] = "_blank" ref["rel"] = "noreferrer noopener" diff --git a/tests/test_buttons.py b/tests/test_buttons.py index 3b928ddb..015ff475 100644 --- a/tests/test_buttons.py +++ b/tests/test_buttons.py @@ -827,3 +827,21 @@ def test_resolve_new_tab_refs_any_marked_element(): assert marked["rel"] == "noreferrer noopener" assert "target" not in unmarked assert "rel" not in unmarked + + +def test_resolve_new_tab_refs_keeps_authored_target(): + """A reference inside a marked element that already has a ``target`` + (e.g. a link with its own attributes nested in a button's text) + is left as authored, while its sibling references are still stamped. + """ + document = new_document("test", get_default_settings(Parser)) + paragraph = nodes.paragraph(sd_new_tab=True) + paragraph += nodes.reference("", "x", refuri="a") + paragraph += nodes.reference("", "y", refuri="b", target="_self", rel="me") + document += paragraph + _resolve_new_tab_refs(None, document, "test") + stamped, authored = document.findall(nodes.reference) + assert stamped["target"] == "_blank" + assert stamped["rel"] == "noreferrer noopener" + assert authored["target"] == "_self" + assert authored["rel"] == "me" From ebd2ac33b4f2a664fb2bdf43c5c74b2e21bbb919 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 10 Nov 2026 00:17:02 +0100 Subject: [PATCH 11/11] =?UTF-8?q?=F0=9F=93=9A=20DOCS:=20say=20a=20new-tab?= =?UTF-8?q?=20card=20opens=20a=20new=20tab=20in=20its=20link-alt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new-tab card examples now follow the page's own advice and name the new tab in link-alt, the stretched link's accessible name; the two card-link snippet fixtures change with them. The option entries say the flags affect HTML-based output (HTML, EPUB), not only HTML. --- docs/badges_buttons.md | 2 +- docs/cards.md | 4 ++-- docs/snippets/myst/card-link.txt | 2 +- docs/snippets/rst/card-link.txt | 2 +- tests/test_snippets/snippet_post_card-link.xml | 2 +- tests/test_snippets/snippet_pre_card-link.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/badges_buttons.md b/docs/badges_buttons.md index 4f607928..36a5ca54 100644 --- a/docs/badges_buttons.md +++ b/docs/badges_buttons.md @@ -283,7 +283,7 @@ new-tab Works for both `button-link` and `button-ref`. Sphinx renders the `rel` attribute only from version 7.4; browsers already treat `target="_blank"` links as `noopener`. - It has no effect on output formats other than HTML. + It affects only HTML-based output (HTML, EPUB); other formats ignore it. tooltip : Add tooltip on hover diff --git a/docs/cards.md b/docs/cards.md index f8a5c251..196dc873 100644 --- a/docs/cards.md +++ b/docs/cards.md @@ -139,7 +139,7 @@ The entire card can be clicked to navigate to `https://example.com`. :::{card} Clickable Card (external, new tab) :link: https://example.com -:link-alt: example.com +:link-alt: example.com (opens in a new tab) :link-new-tab: The entire card can be clicked to open `https://example.com` in a new tab. @@ -299,7 +299,7 @@ link-new-tab Works with all `link-type` values; has no effect without `link`. Sphinx renders the `rel` attribute only from version 7.4; browsers already treat `target="_blank"` links as `noopener`. - It has no effect on output formats other than HTML. + It affects only HTML-based output (HTML, EPUB); other formats ignore it. Tell readers the link opens a new tab, for example in `link-alt`. To open every external link in a new tab, site-wide, see the [sphinx-new-tab-link](https://pypi.org/project/sphinx-new-tab-link/) extension. diff --git a/docs/snippets/myst/card-link.txt b/docs/snippets/myst/card-link.txt index ad1eed14..3b7dbddd 100644 --- a/docs/snippets/myst/card-link.txt +++ b/docs/snippets/myst/card-link.txt @@ -19,7 +19,7 @@ The entire card can be clicked to navigate to . :::{card} Clickable Card (external, new tab) :link: https://example.com -:link-alt: example.com +:link-alt: example.com (opens in a new tab) :link-new-tab: The entire card can be clicked to open in a new tab. diff --git a/docs/snippets/rst/card-link.txt b/docs/snippets/rst/card-link.txt index d1c5a4d7..f7e032e7 100644 --- a/docs/snippets/rst/card-link.txt +++ b/docs/snippets/rst/card-link.txt @@ -18,7 +18,7 @@ Using the ``link`` and ``link-type`` options, you can turn an entire card into a .. card:: Clickable Card (external, new tab) :link: https://example.com - :link-alt: example.com + :link-alt: example.com (opens in a new tab) :link-new-tab: The entire card can be clicked to open https://example.com in a new tab. diff --git a/tests/test_snippets/snippet_post_card-link.xml b/tests/test_snippets/snippet_post_card-link.xml index 63ff2f87..93f7911d 100644 --- a/tests/test_snippets/snippet_post_card-link.xml +++ b/tests/test_snippets/snippet_post_card-link.xml @@ -55,7 +55,7 @@ - example.com + example.com (opens in a new tab) diff --git a/tests/test_snippets/snippet_pre_card-link.xml b/tests/test_snippets/snippet_pre_card-link.xml index fd581955..ab704138 100644 --- a/tests/test_snippets/snippet_pre_card-link.xml +++ b/tests/test_snippets/snippet_pre_card-link.xml @@ -55,7 +55,7 @@ - example.com + example.com (opens in a new tab)