From 2493d2fb15d68e0dd456d06cf626e1c30b2682b4 Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Sat, 9 Sep 2023 19:01:46 +0200 Subject: [PATCH] add is_markdown filter to jinja --- rendercv/__main__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rendercv/__main__.py b/rendercv/__main__.py index 45f2b01..5ce6cd5 100644 --- a/rendercv/__main__.py +++ b/rendercv/__main__.py @@ -31,8 +31,11 @@ if __name__ == "__main__": """ To be continued... """ + if value is None: + raise ValueError("markdown_to_latex should only be used on strings!") + # convert links - link = re.search("\[(.*)\]\((.*?)\)", value) + link = re.search(r"\[(.*)\]\((.*?)\)", value) if link is not None: link = link.groups() oldLinkString = "[" + link[0] + "](" + link[1] + ")" @@ -42,7 +45,17 @@ if __name__ == "__main__": return value + def is_markdown(value: str) -> bool: + """ + To be continued... + """ + if re.search(r"\[(.*)\]\((.*?)\)", value) is not None: + return True + else: + return False + environment.filters["markdown_to_latex"] = markdown_to_latex + environment.filters["is_markdown"] = is_markdown environment.block_start_string = "((*" environment.block_end_string = "*))"