Skip to content

Commit 04b2907

Browse files
authored
Fix #87: allow spaces before and after the page in wikilink (#88)
[[:Folder: en/Bla | Bla]] for example now works.
1 parent 3601ffc commit 04b2907

5 files changed

Lines changed: 7 additions & 8 deletions

File tree

truewiki/namespaces/category/wikilink.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def replace(instance: WikiPage, wikilink: wikitextparser.WikiLink):
1212
# This indicates that the page belongs to this category. We update
1313
# the WikiPage to indicate this, and otherwise remove the WikiLink.
14-
category = wikilink.target[len("category:") :]
14+
category = wikilink.target[len("category:") :].strip()
1515

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

2525

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

2929
# Generate a link to the language root, which will list all categories
3030
# of that language.

truewiki/namespaces/file/wikilink.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313

1414
def link_file(instance: WikiPage, wikilink: wikitextparser.WikiLink):
15-
target = wikilink.target
16-
target = target[len(":file:") :]
15+
target = wikilink.target[len(":file:") :].strip()
1716

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

2827
def link_media(instance: WikiPage, wikilink: wikitextparser.WikiLink):
2928
target = wikilink.target
30-
target = target[len("media:") :]
29+
target = target[len("media:") :].strip()
3130

3231
url = f"File/{target}"
3332

truewiki/namespaces/folder/wikilink.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

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

1414
# As we are browsing folders, [[Folder:en]] and [[Folder:en/]] are
1515
# identical in meaning.

truewiki/namespaces/template/wikilink.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def link_and_replace(instance: WikiPage, wikilink: wikitextparser.WikiLink):
1313

1414
if target.startswith(":"):
1515
target = target[1:]
16-
target = target[len("template:") :]
16+
target = target[len("template:") :].strip()
1717

1818
# Generate a link to the language root, which will list all templates
1919
# of that language.

truewiki/namespaces/translation/wikilink.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

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

1414
error = instance.page_is_valid(f"{page}")
1515
if error:

0 commit comments

Comments
 (0)