Skip to content

Commit

Permalink
Fix #87: allow spaces before and after the page in wikilink (#88)
Browse files Browse the repository at this point in the history
[[:Folder:  en/Bla   | Bla]] for example now works.
  • Loading branch information
TrueBrain authored Nov 14, 2020
1 parent 3601ffc commit 04b2907
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions truewiki/namespaces/category/wikilink.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def replace(instance: WikiPage, wikilink: wikitextparser.WikiLink):
# This indicates that the page belongs to this category. We update
# the WikiPage to indicate this, and otherwise remove the WikiLink.
category = wikilink.target[len("category:") :]
category = wikilink.target[len("category:") :].strip()

error = instance.page_is_valid(f"Category/{category}")
if error:
Expand All @@ -24,7 +24,7 @@ def replace(instance: WikiPage, wikilink: wikitextparser.WikiLink):


def link(instance: WikiPage, wikilink: wikitextparser.WikiLink):
target = wikilink.target[len(":category:") :]
target = wikilink.target[len(":category:") :].strip()

# Generate a link to the language root, which will list all categories
# of that language.
Expand Down
5 changes: 2 additions & 3 deletions truewiki/namespaces/file/wikilink.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@


def link_file(instance: WikiPage, wikilink: wikitextparser.WikiLink):
target = wikilink.target
target = target[len(":file:") :]
target = wikilink.target[len(":file:") :].strip()

# Generate a link to the language root, which will list all templates
# of that language.
Expand All @@ -27,7 +26,7 @@ def link_file(instance: WikiPage, wikilink: wikitextparser.WikiLink):

def link_media(instance: WikiPage, wikilink: wikitextparser.WikiLink):
target = wikilink.target
target = target[len("media:") :]
target = target[len("media:") :].strip()

url = f"File/{target}"

Expand Down
2 changes: 1 addition & 1 deletion truewiki/namespaces/folder/wikilink.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def link(instance: WikiPage, wikilink: wikitextparser.WikiLink):
target = wikilink.target[len(":folder:") :]
target = wikilink.target[len(":folder:") :].strip()

# As we are browsing folders, [[Folder:en]] and [[Folder:en/]] are
# identical in meaning.
Expand Down
2 changes: 1 addition & 1 deletion truewiki/namespaces/template/wikilink.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def link_and_replace(instance: WikiPage, wikilink: wikitextparser.WikiLink):

if target.startswith(":"):
target = target[1:]
target = target[len("template:") :]
target = target[len("template:") :].strip()

# Generate a link to the language root, which will list all templates
# of that language.
Expand Down
2 changes: 1 addition & 1 deletion truewiki/namespaces/translation/wikilink.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def replace(instance: WikiPage, wikilink: wikitextparser.WikiLink):
page = wikilink.target[len("translation:") :]
page = wikilink.target[len("translation:") :].strip()

error = instance.page_is_valid(f"{page}")
if error:
Expand Down

0 comments on commit 04b2907

Please sign in to comment.