Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion myst_parser/myst_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ def _resolve_anchor(
self, node: pending_xref, fromdocname: str
) -> Optional[Element]:
"""Resolve doc with anchor."""
if self.env.config.myst_heading_anchors is None:
# no target anchors will have been created, so we don't look for them
return None
target = node["reftarget"] # type: str
if not ("#" in target and hasattr(self.env, "myst_anchors")):
if "#" not in target:
return None
# the link may be a heading anchor; we need to first get the relative path
rel_path, anchor = target.rsplit("#", 1)
Expand Down
4 changes: 1 addition & 3 deletions myst_parser/sphinx_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ def render_heading(self, token: SyntaxTreeNode) -> None:
clean_astext(section[0]),
)

# for debugging
if not hasattr(self.doc_env, "myst_anchors"):
self.doc_env.myst_anchors = True # type: ignore[attr-defined]
self.doc_env.metadata[self.doc_env.docname]["myst_anchors"] = True
section["myst-anchor"] = doc_slug

def render_math_block_label(self, token: SyntaxTreeNode) -> None:
Expand Down