aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-04-06 16:10:16 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-04-06 16:10:16 +0200
commit3e5f545991bfde434ff2f07982657a1b46c8704e (patch)
treeaf7dac84244734b8e79a657b9d042fb0743800f0
parentc2c8bcab4514d0345df70b868996ae7f3fdab3a6 (diff)
downloadekdosis-3e5f545991bfde434ff2f07982657a1b46c8704e.tar.gz
allow \DeclareNewWitness and \DeclareNewHand in preamble only. new command \SetTEIFileName
-rw-r--r--ekdosis.dtx28
1 files changed, 22 insertions, 6 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 2381af4..535ef81 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -388,12 +388,14 @@ idno={}, msName={}, origDate={}][3]{%
388\NewDocumentCommand{\DeclareNewWitness}{m m O{} +O{}}{% 388\NewDocumentCommand{\DeclareNewWitness}{m m O{} +O{}}{%
389 \declare@new@witness[#3]{#1}{#2}{#4} 389 \declare@new@witness[#3]{#1}{#2}{#4}
390} 390}
391\@onlypreamble\DeclareNewWitness
391\NewDocumentCommand{\DeclareNewHand}{m m m +O{}}{ 392\NewDocumentCommand{\DeclareNewHand}{m m m +O{}}{
392 \luadirect{ekdosis.newhand(\luastringN{#1}, 393 \luadirect{ekdosis.newhand(\luastringN{#1},
393 \luastringN{#2}, 394 \luastringN{#2},
394 \luastringN{#3}, 395 \luastringN{#3},
395 \luastringN{#4})} 396 \luastringN{#4})}
396} 397}
398\@onlypreamble\DeclareNewHand
397\NewDocumentCommand{\getsiglum}{m}{% 399\NewDocumentCommand{\getsiglum}{m}{%
398 \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}% 400 \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}%
399} 401}
@@ -409,6 +411,13 @@ idno={}, msName={}, origDate={}][3]{%
409 \luastringN{#3})} 411 \luastringN{#3})}
410} 412}
411% \end{macrocode} 413% \end{macrocode}
414% Set |TEI| file name
415% \begin{macrocode}
416\NewDocumentCommand{\SetTEIFileName}{m}{
417 \luadirect{ekdosis.setteifilename(\luastringN{#1})}
418}
419\@onlypreamble\SetTEIFileName
420% \end{macrocode}
412% \begin{macrocode} 421% \begin{macrocode}
413\newbool{ekd@started} 422\newbool{ekd@started}
414\newbool{do@app} 423\newbool{do@app}
@@ -807,8 +816,15 @@ function ekdosis.textotei(str)
807 return str 816 return str
808end 817end
809 818
819local teifilename = tex.jobname.."-tei"
820
821function ekdosis.setteifilename(str)
822 teifilename = str
823 return true
824end
825
810function ekdosis.openteistream() 826function ekdosis.openteistream()
811 local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") 827 local f = io.open(teifilename.."_tmp.xml", "a+")
812 f:write("<TEI xmlns=\"http://www.tei-c.org/ns/1.0\">", "\n") 828 f:write("<TEI xmlns=\"http://www.tei-c.org/ns/1.0\">", "\n")
813 f:write("<teiHeader>", "\n") 829 f:write("<teiHeader>", "\n")
814 f:write("<listWit>", "\n") 830 f:write("<listWit>", "\n")
@@ -870,22 +886,22 @@ end
870local tidy = nil 886local tidy = nil
871 887
872function ekdosis.closeteistream(opt) 888function ekdosis.closeteistream(opt)
873 local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") 889 local f = io.open(teifilename.."_tmp.xml", "a+")
874 f:write("\n", "</body>", "\n") 890 f:write("\n", "</body>", "\n")
875 f:write("</text>", "\n") 891 f:write("</text>", "\n")
876 f:write("</TEI>", "\n") 892 f:write("</TEI>", "\n")
877 f:close() 893 f:close()
878 os.remove(tex.jobname.."-tei.xml") 894 os.remove(teifilename..".xml")
879 os.rename(tex.jobname.."_tmp-tei.xml", tex.jobname.."-tei.xml") 895 os.rename(teifilename.."_tmp.xml", teifilename..".xml")
880 if opt == "tidy" then 896 if opt == "tidy" then
881 os.execute("tidy -qmi -xml "..tex.jobname.."-tei.xml") 897 os.execute("tidy -qmi -xml "..teifilename..".xml")
882 else 898 else
883 end 899 end
884 return true 900 return true
885end 901end
886 902
887function ekdosis.exporttei(str) 903function ekdosis.exporttei(str)
888 local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") 904 local f = io.open(teifilename.."_tmp.xml", "a+")
889 str = ekdosis.textotei(str) 905 str = ekdosis.textotei(str)
890 f:write("\n<p>") 906 f:write("\n<p>")
891 f:write(str) 907 f:write(str)