From 0f930082b4e4a77731557691d7ee4d727a781750 Mon Sep 17 00:00:00 2001 From: Jonathan Golder Date: Sat, 11 Mar 2017 11:40:41 +0100 Subject: [PATCH] Also canonicalise anchor parts of articles Replace spaces in anchors with underscores as spaces are not correct there Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=114 FS#114] --- lib/redfam.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/redfam.py b/lib/redfam.py index 6abb7ae..6c045c6 100644 --- a/lib/redfam.py +++ b/lib/redfam.py @@ -288,6 +288,11 @@ class RedFamParser( RedFam ): article = article.split("#", 1) # Replace underscores in title with spaces article[0] = article[0].replace("_", " ") + + if len(article) > 1: + # other way round, replace spaces with underscores in anchors + article[1] = article[1].replace(" ", "_") + # Rejoin title and anchor article = "#".join(article)