Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replacements for another type of input
  • Loading branch information
Klaus Thoden committed Aug 10, 2017
1 parent f8c7c10 commit be68812
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions latex2eoa.py
Expand Up @@ -11,20 +11,20 @@
# to be dealt with: EOAfigure

regex_replacements = {
# r"{\\itshape" : r"\\EOAemph{",
r"\\xref" : r"\\EOAurl",
r"\\uline{\\itshape " : r"\\EOAemph{",
r"{\\itshape " : r"\\EOAemph{",
r"\\uline\{" : r"\\EOAcaps{",
r"\\par" : "\\n\\n",
r"{\\bfseries " : r"\\EOAbold{",
r"\\label\{ftn[0-9]{1,3}}\\footnote" : "\\EOAfn",
r"\\footnote" : r"\\EOAfn",
r"\\label" : r"\\EOAlabel",
r"{enumerate}" : r"{EOAlist}",
r"{itemize}" : r"{EOAitems}",
r"\\color{FF0000}" : r"\\color[rgb]{1,0,0}",
r"\\color{0000FF}" : r"\\color[rgb]{0,0,1}"
r'\$\$(.*?)\$\$' : r"\\begin{EOAequationnonumber}\g<1>\\end{EOAequationnonumber}",
r'\$(.*?)\$' : r"\\EOAineq{\g<1>}",
r'\\section' : r"\\EOAsection",
r'{\\em' : r"\\EOAemph{",
r'\\begin{equation}' : r"\\begin{EOAequation}{equation_label}",
r'\\end{equation}' : r"\\end{EOAequation}",
r'\\(begin|end){quote}' : r"\\\g<1>{EOAquote}",
r'\\(begin|end){itemize}' : r"\\\g<1>{EOAitems}",
r'\\label' : r"\\EOAlabel",
r'\\ref' : r"\\EOAref",
r'\\citet' : r"\\EOAciteauthoryear",
r'{\\bf' : r"\\EOAbold{",
r'\\footnote' : r"\\EOAfn",
r'\\bibliography{' : r"\\EOAbibliographydatabase{"
}

def find_latex_commands(string):
Expand All @@ -44,11 +44,11 @@ def main(infile):
with open(infile, 'r') as input_file:
data = input_file.read()

# list_of_commands = find_latex_commands(input_text)
# list_of_commands = find_latex_commands(data)
# print(list_of_commands)

for instance in regex_replacements.keys():
data = re.sub(instance, regex_replacements[instance], data)

print(data)
# def main ends here

Expand Down

0 comments on commit be68812

Please sign in to comment.