From 3338d24da49b103a0621d5f39ead5142b71d05bc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 23 May 2020 21:33:25 -0400 Subject: [PATCH] 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. --- docs/reference/gtk/gtk-markdown-to-docbook | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/reference/gtk/gtk-markdown-to-docbook b/docs/reference/gtk/gtk-markdown-to-docbook index b461a44230..247c613dce 100755 --- a/docs/reference/gtk/gtk-markdown-to-docbook +++ b/docs/reference/gtk/gtk-markdown-to-docbook @@ -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