summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wikimini/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/wikimini/__init__.py b/wikimini/__init__.py
index 8100a5c..7dc573e 100644
--- a/wikimini/__init__.py
+++ b/wikimini/__init__.py
@@ -243,4 +243,14 @@ def wikicode_to_gemtext(
Returns:
The converted Gemtext.
"""
+ # Avoid calling str() on the whole Wikicode here
+ if (isinstance(obj, mwp.wikicode.Wikicode) and
+ str(mwp.wikicode.Wikicode(obj.nodes[:2])) == "#REDIRECT "):
+ title = str(obj.nodes[2].title)
+ if "#" in title:
+ title, section = title.split("#")
+ section = f"Section '{section}'"
+ else:
+ section = ""
+ return "Redirect:\n=> {} {}\n{}".format(page_url(title), title, section)
return _postprocess(_convert(obj))