From 3e5f545991bfde434ff2f07982657a1b46c8704e Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 6 Apr 2019 16:10:16 +0200 Subject: allow \DeclareNewWitness and \DeclareNewHand in preamble only. new command \SetTEIFileName --- ekdosis.dtx | 28 ++++++++++++++++++++++------ 1 file 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]{% \NewDocumentCommand{\DeclareNewWitness}{m m O{} +O{}}{% \declare@new@witness[#3]{#1}{#2}{#4} } +\@onlypreamble\DeclareNewWitness \NewDocumentCommand{\DeclareNewHand}{m m m +O{}}{ \luadirect{ekdosis.newhand(\luastringN{#1}, \luastringN{#2}, \luastringN{#3}, \luastringN{#4})} } +\@onlypreamble\DeclareNewHand \NewDocumentCommand{\getsiglum}{m}{% \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}% } @@ -409,6 +411,13 @@ idno={}, msName={}, origDate={}][3]{% \luastringN{#3})} } % \end{macrocode} +% Set |TEI| file name +% \begin{macrocode} +\NewDocumentCommand{\SetTEIFileName}{m}{ + \luadirect{ekdosis.setteifilename(\luastringN{#1})} +} +\@onlypreamble\SetTEIFileName +% \end{macrocode} % \begin{macrocode} \newbool{ekd@started} \newbool{do@app} @@ -807,8 +816,15 @@ function ekdosis.textotei(str) return str end +local teifilename = tex.jobname.."-tei" + +function ekdosis.setteifilename(str) + teifilename = str + return true +end + function ekdosis.openteistream() - local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") + local f = io.open(teifilename.."_tmp.xml", "a+") f:write("", "\n") f:write("", "\n") f:write("", "\n") @@ -870,22 +886,22 @@ end local tidy = nil function ekdosis.closeteistream(opt) - local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") + local f = io.open(teifilename.."_tmp.xml", "a+") f:write("\n", "", "\n") f:write("", "\n") f:write("", "\n") f:close() - os.remove(tex.jobname.."-tei.xml") - os.rename(tex.jobname.."_tmp-tei.xml", tex.jobname.."-tei.xml") + os.remove(teifilename..".xml") + os.rename(teifilename.."_tmp.xml", teifilename..".xml") if opt == "tidy" then - os.execute("tidy -qmi -xml "..tex.jobname.."-tei.xml") + os.execute("tidy -qmi -xml "..teifilename..".xml") else end return true end function ekdosis.exporttei(str) - local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") + local f = io.open(teifilename.."_tmp.xml", "a+") str = ekdosis.textotei(str) f:write("\n

") f:write(str) -- cgit v1.2.3