summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wikimini/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/wikimini/__init__.py b/wikimini/__init__.py
index e6bc513..d034d30 100644
--- a/wikimini/__init__.py
+++ b/wikimini/__init__.py
@@ -96,6 +96,22 @@ def render_main(obj: mwp.nodes.template.Template) -> str:
return "Main articles:\n{}\n".format("\n".join(links))
+def render_quote(obj):
+ text = obj.get("text", None)
+ if not text:
+ return ""
+ content = _convert(text.value)
+ lines = content.split("\n")
+ return "\n".join(f"> {line}" for line in lines)
+
+
+def render_cquote(obj):
+ text = obj.params[0]
+ content = _convert(text.value)
+ lines = content.split("\n")
+ return "\n".join(f"> {line}" for line in lines)
+
+
def _convert(obj: Union[mwp.nodes.Node, mwp.wikicode.Wikicode]) -> str:
default = lambda obj: mwp.wikicode.Wikicode([obj]).strip_code(collapse=False)
# This does the actual conversion
@@ -193,6 +209,10 @@ def _convert(obj: Union[mwp.nodes.Node, mwp.wikicode.Wikicode]) -> str:
return "pronounced [{}]".format(_convert(obj.params[0].value))
elif name in {"main", "main article"}:
return render_main(obj)
+ elif name in {"quote", "blockquote"}:
+ return render_quote(obj)
+ elif name == "cquote":
+ return render_cquote(obj)
else:
return default(obj)
elif isinstance(obj, mwp.nodes.wikilink.Wikilink):