diff options
author | Robert Alessi <alessi@robertalessi.net> | 2019-04-02 00:48:31 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2019-04-02 00:48:31 +0200 |
commit | e465827405a0df4f9ace010a934ad6939359d584 (patch) | |
tree | c1519bfe3f04a6594952c2a89e42cc42d3de6281 | |
parent | dc6ffb9a2446468237848fb1d833335e6c98e360 (diff) | |
download | ekdosis-e465827405a0df4f9ace010a934ad6939359d584.tar.gz |
export listWit to teiHeader
-rw-r--r-- | ekdosis.dtx | 78 |
1 files changed, 68 insertions, 10 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index c01189a..549308b 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -324,7 +324,11 @@ Running "make install" installs the files in the local TeX tree. | |||
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\tei@exporttrue\else\fi} | 327 | \if@pkg@teiexport |
328 | \tei@exporttrue | ||
329 | \AtBeginDocument{\luadirect{ekdosis.openteistream()}}% | ||
330 | \AtEndDocument{\luadirect{ekdosis.closeteistream()}} | ||
331 | \else\fi} | ||
328 | \ExecuteOptionsX{} | 332 | \ExecuteOptionsX{} |
329 | \ProcessOptionsX\relax | 333 | \ProcessOptionsX\relax |
330 | \RequirePackage{luacode} | 334 | \RequirePackage{luacode} |
@@ -349,7 +353,6 @@ Running "make install" installs the files in the local TeX tree. | |||
349 | % \begin{macrocode} | 353 | % \begin{macrocode} |
350 | \AtEndDocument{ | 354 | \AtEndDocument{ |
351 | \luadirect{ekdosis.closestream()} | 355 | \luadirect{ekdosis.closestream()} |
352 | \luadirect{ekdosis.closeteistream()} | ||
353 | } | 356 | } |
354 | % \end{macrocode} | 357 | % \end{macrocode} |
355 | % Build and process the list of witnesses and hands. | 358 | % Build and process the list of witnesses and hands. |
@@ -366,10 +369,10 @@ idno={}, msName={}][3]{% | |||
366 | |\luastringN|{\commandkey{idno}}, | 369 | |\luastringN|{\commandkey{idno}}, |
367 | |\luastringN|{\commandkey{msName}})} | 370 | |\luastringN|{\commandkey{msName}})} |
368 | } | 371 | } |
369 | \NewDocumentCommand{\DeclareNewWitness}{m m O{} +m}{% | 372 | \NewDocumentCommand{\DeclareNewWitness}{m m O{} +O{}}{% |
370 | \declare@new@witness[#3]{#1}{#2}{#4} | 373 | \declare@new@witness[#3]{#1}{#2}{#4} |
371 | } | 374 | } |
372 | \NewDocumentCommand{\DeclareNewHand}{m m m +m}{ | 375 | \NewDocumentCommand{\DeclareNewHand}{m m m +O{}}{ |
373 | \luadirect{ekdosis.newhand(\luastringN{#1}, | 376 | \luadirect{ekdosis.newhand(\luastringN{#1}, |
374 | \luastringN{#2}, | 377 | \luastringN{#2}, |
375 | \luastringN{#3}, | 378 | \luastringN{#3}, |
@@ -629,7 +632,7 @@ function ekdosis.newwitness(id, | |||
629 | MsName) | 632 | MsName) |
630 | if xmlidfound(id) | 633 | if xmlidfound(id) |
631 | then | 634 | then |
632 | tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] | 635 | tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] |
633 | ..id.. | 636 | ..id.. |
634 | [[" already exists as a xml:id. ]] | 637 | [[" already exists as a xml:id. ]] |
635 | .. | 638 | .. |
@@ -647,7 +650,6 @@ function ekdosis.newwitness(id, | |||
647 | idno = Idno, | 650 | idno = Idno, |
648 | msName = MsName | 651 | msName = MsName |
649 | }, | 652 | }, |
650 | physDesc = {}, | ||
651 | detailsDesc = description}) | 653 | detailsDesc = description}) |
652 | end | 654 | end |
653 | return true | 655 | return true |
@@ -656,7 +658,7 @@ end | |||
656 | function ekdosis.newhand(id, witid, siglum, description) | 658 | function ekdosis.newhand(id, witid, siglum, description) |
657 | if xmlidfound(id) or not xmlidfound(witid) | 659 | if xmlidfound(id) or not xmlidfound(witid) |
658 | then | 660 | then |
659 | tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] | 661 | tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] |
660 | ..id.. | 662 | ..id.. |
661 | [[" already exists as a xml:id. ]] | 663 | [[" already exists as a xml:id. ]] |
662 | .. | 664 | .. |
@@ -667,9 +669,7 @@ function ekdosis.newhand(id, witid, siglum, description) | |||
667 | table.insert(idsRend, {xmlid = id, head = siglum}) | 669 | table.insert(idsRend, {xmlid = id, head = siglum}) |
668 | table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end) | 670 | table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end) |
669 | local indexwit = getindex(witid, listWit) | 671 | local indexwit = getindex(witid, listWit) |
670 | table.insert(listWit[indexwit].physDesc, {xmlid = id, | 672 | listWit[indexwit].handDesc = {xmlid = id, head = siglum, detailsDesc = description} |
671 | head = siglum, | ||
672 | handDesc = description}) | ||
673 | end | 673 | end |
674 | return true | 674 | return true |
675 | end | 675 | end |
@@ -700,6 +700,7 @@ function ekdosis.getsiglum(str, opt) | |||
700 | end | 700 | end |
701 | 701 | ||
702 | -- begin totei functions | 702 | -- begin totei functions |
703 | |||
703 | local cmdtotags = { | 704 | local cmdtotags = { |
704 | {a="footnote", b="note", c=" place=\"bottom\""}, | 705 | {a="footnote", b="note", c=" place=\"bottom\""}, |
705 | {a="textbf", b="hi", c=" rend=\"bold\""}, | 706 | {a="textbf", b="hi", c=" rend=\"bold\""}, |
@@ -775,7 +776,64 @@ function ekdosis.textotei(str) | |||
775 | return str | 776 | return str |
776 | end | 777 | end |
777 | 778 | ||
779 | function ekdosis.openteistream() | ||
780 | local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") | ||
781 | f:write("<TEI xmlns=\"http://www.tei-c.org/ns/1.0\">", "\n") | ||
782 | f:write("<teiHeader>", "\n") | ||
783 | f:write("<listWit>", "\n") | ||
784 | for i = 1,#listWit do | ||
785 | f:write("<msDesc xml:id=\"", listWit[i].xmlid, "\">", "\n") | ||
786 | f:write("<head>", ekdosis.textotei(listWit[i].head), "</head>", "\n") | ||
787 | if listWit[i].msIdentifier.settlement == "" | ||
788 | and listWit[i].msIdentifier.repository == "" | ||
789 | and listWit[i].msIdentifier.idno == "" | ||
790 | and listWit[i].msIdentifier.msName == "" | ||
791 | then | ||
792 | f:write("<msIdentifier/>", "\n") | ||
793 | else | ||
794 | f:write("<msIdentifier>", "\n") | ||
795 | if listWit[i].msIdentifier.settlement ~= "" then | ||
796 | f:write("<settlement>", ekdosis.textotei(listWit[i].msIdentifier.settlement), "</settlement>", "\n") | ||
797 | else end | ||
798 | if listWit[i].msIdentifier.repository ~= "" then | ||
799 | f:write("<repository>", ekdosis.textotei(listWit[i].msIdentifier.repository), "</repository>", "\n") | ||
800 | else end | ||
801 | if listWit[i].msIdentifier.idno ~= "" then | ||
802 | f:write("<idno>", ekdosis.textotei(listWit[i].msIdentifier.idno), "</idno>", "\n") | ||
803 | else end | ||
804 | if listWit[i].msIdentifier.msName ~= "" then | ||
805 | f:write("<msName>", ekdosis.textotei(listWit[i].msIdentifier.msName), "</msName>", "\n") | ||
806 | else end | ||
807 | f:write("</msIdentifier>", "\n") | ||
808 | end | ||
809 | if listWit[i].handDesc ~= nil then | ||
810 | f:write("<physDesc>", "\n") | ||
811 | f:write("<handDesc xml:id=\"", listWit[i].handDesc.xmlid, "\">", "\n") | ||
812 | f:write("<head>", ekdosis.textotei(listWit[i].handDesc.head), "</head>", "\n") | ||
813 | if listWit[i].handDesc.detailsDesc == "" then else | ||
814 | f:write("<p>", ekdosis.textotei(listWit[i].handDesc.detailsDesc), "</p>", "\n") | ||
815 | end | ||
816 | f:write("</handDesc>", "\n") | ||
817 | f:write("</physDesc>", "\n") | ||
818 | else end | ||
819 | if listWit[i].detailsDesc == "" then else | ||
820 | f:write("<p>", ekdosis.textotei(listWit[i].detailsDesc), "</p>", "\n") | ||
821 | end | ||
822 | f:write("</msDesc>", "\n") | ||
823 | end | ||
824 | f:write("</listWit>", "\n") | ||
825 | f:write("</teiHeader>", "\n") | ||
826 | f:write("<text>", "\n") | ||
827 | f:write("<body>", "\n") | ||
828 | f:close() | ||
829 | return true | ||
830 | end | ||
831 | |||
778 | function ekdosis.closeteistream() | 832 | function ekdosis.closeteistream() |
833 | local f = io.open(tex.jobname.."_tmp-tei.xml", "a+") | ||
834 | f:write("\n", "</body>", "\n") | ||
835 | f:write("</text>", "\n") | ||
836 | f:write("</TEI>", "\n") | ||
779 | os.remove(tex.jobname.."-tei.xml") | 837 | os.remove(tex.jobname.."-tei.xml") |
780 | os.rename(tex.jobname.."_tmp-tei.xml", tex.jobname.."-tei.xml") | 838 | os.rename(tex.jobname.."_tmp-tei.xml", tex.jobname.."-tei.xml") |
781 | return true | 839 | return true |