Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
Klaus Thoden committed Jun 22, 2017
0 parents commit 364baba
Show file tree
Hide file tree
Showing 13 changed files with 2,500 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
__pycache__/
auto/
7 changes: 7 additions & 0 deletions README.md
@@ -0,0 +1,7 @@
# Convert LaTeX to EOAtex

A script to convert LaTeX into EOAtex.

Wolfgang Pauli - Korrespondenz7.docx has been converted to LaTeX using oxgarage and was subsequently converted to EOAtex with this script.


1,070 changes: 1,070 additions & 0 deletions data/TheCorrespondencePrinciple.tex

Large diffs are not rendered by default.

Binary file added data/Wolfgang Pauli - Korrespondenz7.docx
Binary file not shown.
1,362 changes: 1,362 additions & 0 deletions data/Wolfgang Pauli - Korrespondenz7/document.tex

Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions latex2eoa.py
@@ -0,0 +1,59 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-

__version__ = "1.0"
__date__ = "20170621"
__author__ = "kthoden@mpiwg-berlin.mpg.de"

import sys
import re

# 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}"
}

def find_latex_commands(string):
"""Finds latex commands in a text, return a list of unique
occurrences.
"""

command_pattern = re.compile(r'\\[a-zA-Z0-9]+', re.UNICODE)
found_commands = set(re.findall(command_pattern, string))

return found_commands
# def find_latex_commands ends here

def main(infile):
"""The main bit"""

with open(infile, 'r') as input_file:
data = input_file.read()

# list_of_commands = find_latex_commands(input_text)

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

print(data)
# def main ends here

if __name__ == '__main__':
infile = sys.argv[-1]
main(infile)
# finis

0 comments on commit 364baba

Please sign in to comment.