From a94aa3ae8e6ccb82abc67e1bda7fed168c86de92 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 6 Apr 2019 11:02:22 +0200 Subject: accept spaces between commands inside \app. new option teiexport=tidy (needs --shell-escape) --- ekdosis.dtx | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index cecdbbc..dfaf163 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -323,12 +323,27 @@ Running "make install" installs the files in the local TeX tree. \fi\fi\fi }{\PackageWarning{ekdosis}{parnotes: erroneous input (ignored)}} \newif\iftei@export -\define@boolkey{ekdosis.sty}[@pkg@]{teiexport}[true]{% - \if@pkg@teiexport +% \define@boolkey{ekdosis.sty}[@pkg@]{teiexport}[true]{% +% \if@pkg@teiexport +% \tei@exporttrue +% \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% +% \AtEndDocument{\luadirect{ekdosis.closeteistream()}} +% \else\fi} +\define@choicekey{ekdosis.sty}{teiexport}{true, false, tidy}[true]{% + \edef\@exptrue{true}\edef\@expfalse{false}\edef\@exptidy{tidy} + \edef\@tempa{#1} + \ifx\@tempa\@expfalse + \else + \ifx\@tempa\@exptrue \tei@exporttrue \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% \AtEndDocument{\luadirect{ekdosis.closeteistream()}} - \else\fi} + \else + \ifx\@tempa\@exptidy + \tei@exporttrue + \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% + \AtEndDocument{\luadirect{ekdosis.closeteistream("tidy")}} + \else\fi\fi\fi} \ExecuteOptionsX{} \ProcessOptionsX\relax \RequirePackage{luacode} @@ -453,7 +468,7 @@ idno={}, msName={}, origDate={}][3]{% ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}}, "pg_ii")}% \ifbool{ekd@state}{\add@apparatus}{}% - #1% + \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#1}))}% \ekd@isinappfalse} \newkeycommand+[\|]{\lem}[wit, alt, pre, post, prewit, postwit, choice nolem={false,,true}][1]{% @@ -852,13 +867,20 @@ function ekdosis.openteistream() return true end -function ekdosis.closeteistream() +local tidy = nil + +function ekdosis.closeteistream(opt) local f = io.open(tex.jobname.."_tmp-tei.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") + if opt == "tidy" then + os.execute("tidy -qmi -xml "..tex.jobname.."-tei.xml") + else + end return true end @@ -898,6 +920,11 @@ function ekdosis.basic_cs(msid) end -- end basic TeX Conspectus siglorum +function ekdosis.removesp(str) + str = string.gsub(str, "(%b{})(%s+)", "%1") + return str +end + function ekdosis.closestream() os.remove(tex.jobname..".ekd") os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd") -- cgit v1.2.3