docs: Be more careful when expanding abbreviations

We must not expand #symbol in the middle of a url,
where it is probably a fragment identifier. Restrict
problem.
This commit is contained in:
Matthias Clasen 2020-05-23 21:33:25 -04:00
parent 10cd539104
commit 3338d24da4

View File

@ -37,10 +37,13 @@ def ExpandAbbreviations(symbol, text):
text = re.sub(r'\\\%', r'\%', text)
# Convert '#symbol', but not '\#symbol'.
# Only convert #foo after a space to avoid interfering with
# fragment identifiers in urls
def f3(m):
return m.group(1) + MakeHashXRef(m.group(2), "type")
text = re.sub(r'(\A|[^\\])#([\w\-:\.]+[\w]+)', f3, text)
text = re.sub(r'(\A|[ ])#([\w\-:\.]+[\w]+)', f3, text)
text = re.sub(r'\\#', '#', text)
return text