Skip to content

Commit

Permalink
An XML-unaware fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaus Thoden committed Feb 12, 2018
1 parent 35f283a commit 95b0467
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions eoaconvert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2018-02-12 16:42:59 (kthoden)>
# Time-stamp: <2018-02-12 16:57:53 (kthoden)>

# license?
__version__= "1.0"
Expand Down Expand Up @@ -1547,11 +1547,24 @@ def cleanup():
# here followed the conversion to epub and the conversion to django.xml
# both parts were removed and put into separate files.

ergebnisdatei = open("tmp_files/IntermediateXMLFile.xml", "w")
intermediate_file = "tmp_files/IntermediateXMLFile.xml"
ergebnisdatei = open(intermediate_file, "w")
ergebnis = etree.tostring(xmlTree, pretty_print=True, encoding="unicode")
ergebnisdatei.write(ergebnis)
ergebnisdatei.close()

# replacing a milestone element by a closing and opening combination
with open(intermediate_file, 'r') as tmp_file:
filedata = tmp_file.read()

# Replace the target string
filedata = filedata.replace('<msparbreak/>', '</p><p>')

# Write the file out again
with open(intermediate_file, 'w') as outfile:
outfile.write(filedata)

# saving some data
data_to_pickle = {'chapterdict' : dictChapters,
'eqdict' : dictEquations,
'listdict' : dictLists,
Expand Down

0 comments on commit 95b0467

Please sign in to comment.