From 2fdee0eddbb03f4d12888b53b5d0bc5b9aaf0c81 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 20 Apr 2019 18:35:09 +0200 Subject: new functions ekdosis.newscholar() and ekdosis.setxmlbibresource(); import .xml bib file into main TEI file --- ekdosis.dtx | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ekdosis.dtx b/ekdosis.dtx index 7687345..690f8f5 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -399,6 +399,11 @@ idno={}, msName={}, origDate={}][3]{% \luastringN{#4})} } \@onlypreamble\DeclareNewHand +\NewDocumentCommand{\DeclareNewScholar}{m m}{ + \luadirect{ekdosis.newscholar(\luastringN{#1}, + \luastringN{#2})} +} +\@onlypreamble\DeclareNewScholar \NewDocumentCommand{\getsiglum}{m}{% \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}% } @@ -420,6 +425,10 @@ idno={}, msName={}, origDate={}][3]{% \luadirect{ekdosis.setteifilename(\luastringN{#1})} } \@onlypreamble\SetTEIFileName +\NewDocumentCommand{\SetxmlBibResource}{m}{ + \luadirect{ekdosis.setxmlbibresource(\luastringN{#1})} +} +\@onlypreamble\SetxmlBibResource % \end{macrocode} % \begin{macrocode} \newbool{ekd@started} @@ -748,6 +757,30 @@ function ekdosis.newhand(id, witid, siglum, description) return true end +local xmlbibresource = nil + +function ekdosis.setxmlbibresource(str) + xmlbibresource = str..".xml" + return true +end + +function ekdosis.newscholar(id, siglum) + if xmlidfound(id) + then + tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] + ..id.. + [[" already exists as a xml:id. ]] + .. + [[Please pick another id.}}]]) + else + table.insert(xmlids, {xmlid = id}) + table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) + table.insert(idsRend, {xmlid = id, head = siglum}) + table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end) + end + return true +end + function ekdosis.getsiglum(str, opt) str = str.."," str = string.gsub(str, "%s-(%,)", "%1") @@ -876,6 +909,7 @@ end function ekdosis.openteistream() local f = io.open(teifilename.."_tmp.xml", "a+") + f:write('', "\n") f:write("", "\n") f:write("", "\n") f:write("", "\n") @@ -944,6 +978,20 @@ local tidy = nil function ekdosis.closeteistream(opt) local f = io.open(teifilename.."_tmp.xml", "a+") f:write("\n", "", "\n") + if xmlbibresource ~= nil then + bibf = assert(io.open(xmlbibresource, "r")) + t = bibf:read("*a") + f:write("", "\n") + f:write("", "\n") + for i in string.gmatch(t, ".-") + do + f:write("\n", i, "\n") + end + f:write("", "\n") + f:write("", "\n") + bibf:close() + else + end f:write("", "\n") f:write("", "\n") f:close() -- cgit v1.2.3