diff options
author | Daniel Schadt <kingdread@gmx.de> | 2021-08-16 15:58:06 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2021-08-16 15:58:06 +0200 |
commit | ddb780ea97386352196718ea250c120fbfae3ec5 (patch) | |
tree | 10be19512abf17b7a467b3f5b13215b35d3e8e73 | |
parent | 44479eaa07a177691326291a4d32ac7cd4f61cce (diff) | |
download | wikimini-ddb780ea97386352196718ea250c120fbfae3ec5.tar.gz wikimini-ddb780ea97386352196718ea250c120fbfae3ec5.tar.bz2 wikimini-ddb780ea97386352196718ea250c120fbfae3ec5.zip |
Add a redirection page
-rw-r--r-- | wikimini/__init__.py | 10 |
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)) |