diff options
author | Robert Alessi <alessi@robertalessi.net> | 2019-04-06 11:02:22 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2019-04-06 11:02:22 +0200 |
commit | a94aa3ae8e6ccb82abc67e1bda7fed168c86de92 (patch) | |
tree | 0545977a3fb3e6107e3ce59fc3bb21e06299a0b0 /ekdosis.dtx | |
parent | 376583efb5d484c509d0f6e2c942032f461b8a98 (diff) | |
download | ekdosis-a94aa3ae8e6ccb82abc67e1bda7fed168c86de92.tar.gz |
accept spaces between commands inside \app. new option teiexport=tidy (needs --shell-escape)
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r-- | ekdosis.dtx | 37 |
1 files 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. | |||
323 | \fi\fi\fi | 323 | \fi\fi\fi |
324 | }{\PackageWarning{ekdosis}{parnotes: erroneous input (ignored)}} | 324 | }{\PackageWarning{ekdosis}{parnotes: erroneous input (ignored)}} |
325 | \newif\iftei@export | 325 | \newif\iftei@export |
326 | \define@boolkey{ekdosis.sty}[@pkg@]{teiexport}[true]{% | 326 | % \define@boolkey{ekdosis.sty}[@pkg@]{teiexport}[true]{% |
327 | \if@pkg@teiexport | 327 | % \if@pkg@teiexport |
328 | % \tei@exporttrue | ||
329 | % \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% | ||
330 | % \AtEndDocument{\luadirect{ekdosis.closeteistream()}} | ||
331 | % \else\fi} | ||
332 | \define@choicekey{ekdosis.sty}{teiexport}{true, false, tidy}[true]{% | ||
333 | \edef\@exptrue{true}\edef\@expfalse{false}\edef\@exptidy{tidy} | ||
334 | \edef\@tempa{#1} | ||
335 | \ifx\@tempa\@expfalse | ||
336 | \else | ||
337 | \ifx\@tempa\@exptrue | ||
328 | \tei@exporttrue | 338 | \tei@exporttrue |
329 | \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% | 339 | \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% |
330 | \AtEndDocument{\luadirect{ekdosis.closeteistream()}} | 340 | \AtEndDocument{\luadirect{ekdosis.closeteistream()}} |
331 | \else\fi} | 341 | \else |
342 | \ifx\@tempa\@exptidy | ||
343 | \tei@exporttrue | ||
344 | \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% | ||
345 | \AtEndDocument{\luadirect{ekdosis.closeteistream("tidy")}} | ||
346 | \else\fi\fi\fi} | ||
332 | \ExecuteOptionsX{} | 347 | \ExecuteOptionsX{} |
333 | \ProcessOptionsX\relax | 348 | \ProcessOptionsX\relax |
334 | \RequirePackage{luacode} | 349 | \RequirePackage{luacode} |
@@ -453,7 +468,7 @@ idno={}, msName={}, origDate={}][3]{% | |||
453 | ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}}, | 468 | ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}}, |
454 | "pg_ii")}% | 469 | "pg_ii")}% |
455 | \ifbool{ekd@state}{\add@apparatus}{}% | 470 | \ifbool{ekd@state}{\add@apparatus}{}% |
456 | #1% | 471 | \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#1}))}% |
457 | \ekd@isinappfalse} | 472 | \ekd@isinappfalse} |
458 | \newkeycommand+[\|]{\lem}[wit, alt, pre, post, prewit, postwit, | 473 | \newkeycommand+[\|]{\lem}[wit, alt, pre, post, prewit, postwit, |
459 | choice nolem={false,,true}][1]{% | 474 | choice nolem={false,,true}][1]{% |
@@ -852,13 +867,20 @@ function ekdosis.openteistream() | |||
852 | return true | 867 | return true |
853 | end | 868 | end |
854 | 869 | ||
855 | function ekdosis.closeteistream() | 870 | local tidy = nil |
871 | |||
872 | function ekdosis.closeteistream(opt) | ||
856 | local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") | 873 | local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") |
857 | f:write("\n", "</body>", "\n") | 874 | f:write("\n", "</body>", "\n") |
858 | f:write("</text>", "\n") | 875 | f:write("</text>", "\n") |
859 | f:write("</TEI>", "\n") | 876 | f:write("</TEI>", "\n") |
877 | f:close() | ||
860 | os.remove(tex.jobname.."-tei.xml") | 878 | os.remove(tex.jobname.."-tei.xml") |
861 | os.rename(tex.jobname.."_tmp-tei.xml", tex.jobname.."-tei.xml") | 879 | os.rename(tex.jobname.."_tmp-tei.xml", tex.jobname.."-tei.xml") |
880 | if opt == "tidy" then | ||
881 | os.execute("tidy -qmi -xml "..tex.jobname.."-tei.xml") | ||
882 | else | ||
883 | end | ||
862 | return true | 884 | return true |
863 | end | 885 | end |
864 | 886 | ||
@@ -898,6 +920,11 @@ function ekdosis.basic_cs(msid) | |||
898 | end | 920 | end |
899 | -- end basic TeX Conspectus siglorum | 921 | -- end basic TeX Conspectus siglorum |
900 | 922 | ||
923 | function ekdosis.removesp(str) | ||
924 | str = string.gsub(str, "(%b{})(%s+)", "%1") | ||
925 | return str | ||
926 | end | ||
927 | |||
901 | function ekdosis.closestream() | 928 | function ekdosis.closestream() |
902 | os.remove(tex.jobname..".ekd") | 929 | os.remove(tex.jobname..".ekd") |
903 | os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd") | 930 | os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd") |