From f37efe06e285c88085f3528943ef231555c3af03 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Thu, 22 Sep 2022 20:53:27 -0700 Subject: [PATCH] Add `cat` macro This concatenates all the arguments without spaces. Signed-off-by: Alek Ratzloff --- markup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/markup.py b/markup.py index 058530a..220ca34 100755 --- a/markup.py +++ b/markup.py @@ -246,6 +246,11 @@ def macro_round(ctx: MarkupContext, n: str, digits: Optional[str] = None) -> str return str(res) +def macro_cat(ctx: MarkupContext, *text: str) -> str: + "Concatenates all arguments." + return ''.join(text) + + @functools.cache def default_context(): c = MarkupContext() @@ -253,6 +258,8 @@ def default_context(): c.register_macro("choose", macro_choose) c.register_macro("round", macro_round) + c.register_macro("cat", macro_cat) + return c