Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Blog Mathjax Converter Short Edition
'''
Blog converter short
For Mathjax only
XGN from HHS 2021/2/27
'''
def blogalize(s):
s=s.replace("%","%").replace("{{","{ {").replace("}}","} }").replace("$$","$")
so=""
left=True
for i in s:
if i=="$":
if left:
so+="{% mathjax %}"
else:
so+="{% endmathjax %}"
left=not left
else:
so+=i
return so
with open("in.txt",mode="r",encoding="utf-8") as f:
with open("out.txt",mode="w",encoding="utf-8") as f2:
f2.write(blogalize("".join(f.readlines())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment