add is_markdown filter to jinja

This commit is contained in:
Sina Atalay 2023-09-09 19:01:46 +02:00
parent 547cffefe6
commit 2493d2fb15
1 changed files with 14 additions and 1 deletions

View File

@ -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 = "*))"