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