Created
February 28, 2018 03:30
-
-
Save qykong/e51a2f6a2be8d34687941fd9370094d6 to your computer and use it in GitHub Desktop.
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
from urllib import parse | |
import re | |
import argparse | |
def return_md_image(latex_string): | |
return '}) + '&mode=inline)' | |
def convert_md(input_file, outputfile): | |
with open(input_file, 'r') as ifile: | |
content = ''.join(ifile.readlines()) | |
p = re.compile(' (\$.*?\$)') | |
latexes = p.findall(content) | |
for ls in latexes: | |
content = content.replace(ls, return_md_image(ls)) | |
with open(outputfile, 'w') as f: | |
f.write(content) | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--input', help = 'input file path') | |
parser.add_argument('--output', help = 'output file path') | |
args = parser.parse_args() | |
convert_md(args.input, args.output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment