Add cat macro

This concatenates all the arguments without spaces.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-09-22 20:53:27 -07:00
parent 4d221a2658
commit f37efe06e2

View File

@@ -246,6 +246,11 @@ def macro_round(ctx: MarkupContext, n: str, digits: Optional[str] = None) -> str
return str(res) return str(res)
def macro_cat(ctx: MarkupContext, *text: str) -> str:
"Concatenates all arguments."
return ''.join(text)
@functools.cache @functools.cache
def default_context(): def default_context():
c = MarkupContext() c = MarkupContext()
@@ -253,6 +258,8 @@ def default_context():
c.register_macro("choose", macro_choose) c.register_macro("choose", macro_choose)
c.register_macro("round", macro_round) c.register_macro("round", macro_round)
c.register_macro("cat", macro_cat)
return c return c