Skip to content

Instantly share code, notes, and snippets.

@XiaoGeNintendo
Created February 27, 2021 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XiaoGeNintendo/01f86d40bc3c129bdbae8e014a2826d3 to your computer and use it in GitHub Desktop.
Save XiaoGeNintendo/01f86d40bc3c129bdbae8e014a2826d3 to your computer and use it in GitHub Desktop.
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