diff options
author | Robert Alessi <alessi@robertalessi.net> | 2019-04-26 17:23:47 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2019-04-26 17:23:47 +0200 |
commit | ff786c88dd442a9744f33fe36cf28fdd9be0368e (patch) | |
tree | 93382ff011931b3cb562f27ba909736f478d5358 | |
parent | a7ed6e42996771616d6810bb8e350c1f55d294a3 (diff) | |
download | ekdosis-ff786c88dd442a9744f33fe36cf28fdd9be0368e.tar.gz |
new (experimental) function cleanup_tei()
-rw-r--r-- | ekdosis.dtx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index 2d4579c..056d13e 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -1115,6 +1115,17 @@ end | |||
1115 | 1115 | ||
1116 | local tidy = nil | 1116 | local tidy = nil |
1117 | 1117 | ||
1118 | local function cleanup_tei() | ||
1119 | local f = assert(io.open(teifilename.."_tmp.xml", "r")) | ||
1120 | t = f:read("*a") | ||
1121 | t = string.gsub(t, "%<p%>%</p%>\n", "") | ||
1122 | t = string.gsub(t, "^\n", "") | ||
1123 | local fw = assert(io.open(teifilename.."_tmp.xml", "w")) | ||
1124 | fw:write(t) | ||
1125 | fw:close() | ||
1126 | return true | ||
1127 | end | ||
1128 | |||
1118 | function ekdosis.closeteistream(opt) | 1129 | function ekdosis.closeteistream(opt) |
1119 | local f = io.open(teifilename.."_tmp.xml", "a+") | 1130 | local f = io.open(teifilename.."_tmp.xml", "a+") |
1120 | f:write("\n", "</body>", "\n") | 1131 | f:write("\n", "</body>", "\n") |
@@ -1136,6 +1147,7 @@ function ekdosis.closeteistream(opt) | |||
1136 | f:write("</text>", "\n") | 1147 | f:write("</text>", "\n") |
1137 | f:write("</TEI>", "\n") | 1148 | f:write("</TEI>", "\n") |
1138 | f:close() | 1149 | f:close() |
1150 | cleanup_tei() | ||
1139 | os.remove(teifilename..".xml") | 1151 | os.remove(teifilename..".xml") |
1140 | os.rename(teifilename.."_tmp.xml", teifilename..".xml") | 1152 | os.rename(teifilename.."_tmp.xml", teifilename..".xml") |
1141 | if opt == "tidy" then | 1153 | if opt == "tidy" then |