summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wikimini/__init__.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/wikimini/__init__.py b/wikimini/__init__.py
index 12c3f31..8100a5c 100644
--- a/wikimini/__init__.py
+++ b/wikimini/__init__.py
@@ -118,6 +118,20 @@ def _convert(obj: Union[mwp.nodes.Node, mwp.wikicode.Wikicode]) -> str:
_convert(after),
))
continue
+ # Pattern: *[[Wikilink]]\n
+ elif (i >= 1 and
+ i + 1 < len(obj.nodes) and
+ re.match("s?\n", str(obj.nodes[i+1])) and
+ isinstance(node, mwp.nodes.wikilink.Wikilink) and
+ str(obj.nodes[i-1]) == "*"):
+ converted.pop()
+ _, after = next(iterator)
+ converted.append("=> {} {}{}".format(
+ page_url(str(node.title)),
+ _convert(node),
+ _convert(after),
+ ))
+ continue
# Default: Just convert the node
converted.append(_convert(node))
@@ -128,9 +142,9 @@ def _convert(obj: Union[mwp.nodes.Node, mwp.wikicode.Wikicode]) -> str:
# Most tags are handled just fine and can be delegated to strip_code
# (inline text styles), however we can do a bit better for list tags.
if str(obj.wiki_markup) == "*":
- return "*"
+ return "* "
elif str(obj.wiki_markup) == "#":
- return "<!NUM!> {}".format(_convert(obj.contents))
+ return "<!NUM!> "
elif str(obj.tag) == "ref":
return ""
elif str(obj.tag) == "table":