Skip to content

Commit

Permalink
馃悰 FIX: Heading anchor resolution for parallel builds (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Feb 23, 2022
1 parent 5b213fa commit 0bc41ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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

0 comments on commit 0bc41ef

Please sign in to comment.