-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate.py
76 lines (57 loc) · 3.06 KB
/
create.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import codecs
from subprocess import call
def writeToFile(path, contents):
destination = codecs.open(path, 'w', 'utf-8')
destination.write(contents)
destination.close()
def getTemplateText():
source = open('./personal_greek_reader.tex')
return source.read()
def getTextOfSubFile(filename):
source = open('./docs/' + filename)
return source.read()
#Personalize below
#These are the supported font sizes: 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, and 20pt.
#See http://ctan.mackichan.com/macros/latex/contrib/extsizes/extsizes.pdf for more info.
docOptions = [
#This one defines the filename and sizes for the large text version
{ 'filename_extension': '_treadmill', 'fontsize': '20', 'footnotesize': '17' },
#The normal version
{ 'filename_extension': '', 'fontsize': '14', 'footnotesize': '12' },
#If you want a third version, you can add it.
]
#You won't read the same texts I read, so create your own files in the "docs" directory and
# add them here. They will be added to the output in the order you specify below.
subtextFilenames = [
#{ 'file': 'eusebius_commentary_on_isaiah.tex', 'title': 'Eusebius, Commentary on Isaiah', 'version': '_0_1_1' },
#{ 'file': 'lxx_psalms.tex', 'title': 'Psalms (LXX)', 'version': '_0_1_1' },
#{ 'file': 'lxx_isaiah.tex', 'title': 'Isaiah (LXX)', 'version': '_0_1_1' },
#{ 'file': 'lxx_habbakuk.tex', 'title': 'Habakkuk (LXX)', 'version': '_0_1_1' },
{ 'file': 'plato_euthyphro.tex', 'title': 'Plato, Euthyphro', 'version': '_0_4_0'},
{ 'file': 'theophilus_to_autolycus.tex', 'title': 'Theophylus to Autolycus', 'version': '_0_1_1' },
{ 'file': 'fabulae_faciles.tex', 'title': 'Fabulae Faciles', 'version': '_0_1_2' }
]
template = getTemplateText()
for doc in subtextFilenames:
allSubtextData = ''
allSubtextData = allSubtextData + '\n\n\n\n\n\n\n%----------------------------------'
allSubtextData = allSubtextData + '\n%New File - ' + doc['file']
allSubtextData = allSubtextData + getTextOfSubFile(doc['file'])
for optionSet in docOptions:
template = getTemplateText()
output = template.replace('$text$', allSubtextData)
output = output.replace('$title$', doc['title'])
output = output.replace('$textsize$', optionSet['fontsize'])
output = output.replace('$footnotesize$', optionSet['footnotesize'])
outputFilename = doc['file'].replace('.tex', '') + optionSet['filename_extension']
writeToFile(outputFilename + '.tex', output)
call(['xelatex', outputFilename + '.tex'])
#Yes, this needs to be called twice, for the TOC. Whacky.
call(['xelatex', outputFilename + '.tex'])
call(['cp', outputFilename + '.pdf', '/Users/ericsowell/Dropbox/Mobile/' + outputFilename + doc['version'] + '.pdf'])
#call(['open', outputFilename + '.pdf'])
call(['rm', outputFilename + '.aux'])
call(['rm', outputFilename + '.log'])
call(['rm', outputFilename + '.out'])
call(['rm', outputFilename + '.tex'])
call(['rm', outputFilename + '.toc'])