diff --git a/lib/redfam.py b/lib/redfam.py index dc1535d..6c045c6 100644 --- a/lib/redfam.py +++ b/lib/redfam.py @@ -280,8 +280,26 @@ class RedFamParser( RedFam ): # (Task FS#77) heading = mwparser.parse( str( heading ) ) - # Save destinations of wikilinks in headings - return [ str( link.title ) for link in heading.ifilter_wikilinks() ] + articlesList = [] + for link in heading.ifilter_wikilinks(): + article = str( link.title ) + + # Split in title and anchor part + 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) + + # Add to list + articlesList.append(article) + + return articlesList def add_beginning( self, beginning ): """