diff --git a/docs/sphinx/_ext/sphinx-mdx-builder/sphinxcontrib/mdxbuilder/writers/mdx.py b/docs/sphinx/_ext/sphinx-mdx-builder/sphinxcontrib/mdxbuilder/writers/mdx.py index 84f5d2050de0d..857ca92f62b95 100644 --- a/docs/sphinx/_ext/sphinx-mdx-builder/sphinxcontrib/mdxbuilder/writers/mdx.py +++ b/docs/sphinx/_ext/sphinx-mdx-builder/sphinxcontrib/mdxbuilder/writers/mdx.py @@ -576,15 +576,35 @@ def depart_paragraph(self, node: Element) -> None: self.end_state(wrap=False) def visit_reference(self, node: Element) -> None: - ref_text = node.astext() - if "refuri" in node: - self.reference_uri = node["refuri"] - elif "refid" in node: - self.reference_uri = f"#{node['refid']}" - else: - self.messages.append('References must have "refuri" or "refid" attribute.') + if len(node.children) == 1 and isinstance( + node.children[0], (nodes.literal, addnodes.literal_emphasis) + ): + # For references containing only a literal or literal_emphasis, use the literal text + ref_text = node.children[0].astext() + if "refuri" in node: + self.reference_uri = node["refuri"] + elif "refid" in node: + self.reference_uri = f"#{node['refid']}" + else: + self.messages.append('References must have "refuri" or "refid" attribute.') + raise nodes.SkipNode + # Use _emphasis for literal_emphasis nodes + if isinstance(node.children[0], addnodes.literal_emphasis): + self.add_text(f"[*{ref_text}*]({self.reference_uri})") + else: + self.add_text(f"[`{ref_text}`]({self.reference_uri})") raise nodes.SkipNode - self.add_text(f"[{ref_text}]({self.reference_uri})") + else: + # Handle regular references + ref_text = node.astext() + if "refuri" in node: + self.reference_uri = node["refuri"] + elif "refid" in node: + self.reference_uri = f"#{node['refid']}" + else: + self.messages.append('References must have "refuri" or "refid" attribute.') + raise nodes.SkipNode + self.add_text(f"[{ref_text}]({self.reference_uri})") def depart_reference(self, node: Element) -> None: self.reference_uri = "" @@ -803,7 +823,6 @@ def depart_block_quote(self, node: Element) -> None: def visit_transition(self, node: Element) -> None: self.new_state(0) - self.add_text("-----") def depart_transition(self, node: Element) -> None: self.end_state(wrap=False)