Created
February 27, 2021 05:26
-
-
Save XiaoGeNintendo/01f86d40bc3c129bdbae8e014a2826d3 to your computer and use it in GitHub Desktop.
Blog Mathjax Converter Short Edition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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