Skip to content
Merged
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
21 changes: 5 additions & 16 deletions generator/_scripts/cfdoc_linkresolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,12 @@ def addLinkToMap(keyword, anchor, html, config):


def headerToAnchor(header):
# remove trailing hashes, allowed in markdown and
# interpreted by us to not include the header in the link map
anchor = header.lower()
anchor = anchor.rstrip("#").rstrip()
anchor = anchor.replace("--", "-")
# Match Hugo's heading ids (goldmark, "github" autoHeadingIDType): lowercase,
# drop all but alphanumerics, "-" and "_", spaces to "-". Punctuation is
# dropped, not replaced: "sys.uqhost" -> "sysuqhost".
anchor = header.rstrip("#").rstrip().lower()
anchor = re.sub(r"[^\w\- ]", "", anchor, flags=re.UNICODE)
anchor = anchor.replace(" ", "-")
anchor = anchor.replace(":", "-")
anchor = anchor.replace(".", "-")
anchor = anchor.replace(",", "-")
anchor = anchor.replace("`", "-")
anchor = anchor.replace("/", "-")
anchor = anchor.replace("$", "-")
anchor = anchor.replace("(", "-")
anchor = anchor.replace(")", "-")
anchor = anchor.replace("--", "-")
anchor = anchor.replace('"', "")
anchor = anchor.lstrip("-").rstrip("-")
return anchor


Expand Down
Loading