From dc7c60c90a10154ed0870caf3f6b9bee4add29f4 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 31 Mar 2019 22:33:05 +0200 Subject: working on \DeclareNewWitness --- ekdosis.dtx | 76 ++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 1328c4e..17a97da 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -354,10 +354,25 @@ Running "make install" installs the files in the local TeX tree. % \end{macrocode} % Build and process the list of witnesses and hands % \begin{macrocode} -\NewDocumentCommand{\DeclareNewWitness}{m m +m}{ - \luadirect{ekdosis.newwitness(\luastringN{#1}, - \luastringN{#2}, - \luastringN{#3})} +% \NewDocumentCommand{\DeclareNewWitness}{m m +m}{ +% \luadirect{ekdosis.newwitness(\luastringN{#1}, +% \luastringN{#2}, +% \luastringN{#3})} +% } +\newkeycommand+[\|]{\declare@new@witness}[settlement={}, repository={}, +idno={}, msName={}][3]{% + |\luadirect|{% + ekdosis.newwitness( + |\luastringN|{#1}, + |\luastringN|{#2}, + |\luastringN|{#3}, + |\luastringN|{\commandkey{settlement}}, + |\luastringN|{\commandkey{repository}}, + |\luastringN|{\commandkey{idno}}, + |\luastringN|{\commandkey{msName}})} +} +\NewDocumentCommand{\DeclareNewWitness}{m m O{} +m}{% + \declare@new@witness[#3]{#1}{#2}{#4} } \NewDocumentCommand{\DeclareNewHand}{m m m +m}{ \luadirect{ekdosis.newhand(\luastringN{#1}, @@ -470,10 +485,11 @@ choice nolem={false,,true}][1]{% % \define@key[ekd]{lemma}{wit}{\getsiglum{#1}} % \define@key[ekd]{lemma}{tchic}{#1} % \presetkeys[ekd]{lemma}{wit={},tchic={}}{} -% \def\mgetsiglum#1{\setkeys[ekd]{lemma}[tchic]{#1}} +% \def\m@getsiglum#1{\setkeys[ekd]{lemma}[tchic]{#1}} % \def\mtchic#1{\setkeys[ekd]{lemma}[wit]{#1}} % \NewDocumentCommand{\mrdg}{O{} +m}{% -% \append@app{#2 \mtchic{#1}\mgetsiglum{#1}\mtchic{#1}}% +% \setkeys[ekd]{lemma}[tchic]{#1} +% \append@app{#2 \csname m@getsiglum\endcsname{#1}}% % } \newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit][1]{% |\ifbool{al@rlmode}|% @@ -596,8 +612,6 @@ local function isintable(table, value) return false end -local sorted_no = 0 - local function getindex(id, table) local idfound = nil for i = 1,#table @@ -610,33 +624,43 @@ local function getindex(id, table) return idfound end -function ekdosis.newwitness(id, siglum, description) +function ekdosis.newwitness(id, + siglum, + description, + Settlement, + Repository, + Idno, + MsName) if xmlidfound(id) then - tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] + tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] ..id.. [[" already exists as a xml:id. ]] .. [[Please pick another id.}}]]) else - sorted_no = sorted_no + 1 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) table.insert(listWit, {xmlid = id, head = siglum, - msIdentifier = {}, + msIdentifier = { + settlement = Settlement, + repository = Repository, + idno = Idno, + msName = MsName + }, physDesc = {}, - description = {}, - sorted = sorted_no}) - table.sort(listWit, function(a ,b) return(#a.xmlid > #b.xmlid) end) + detailsDesc = description}) end return true end function ekdosis.newhand(id, witid, siglum, description) - if xmlidfound(id) + if xmlidfound(id) or not xmlidfound(witid) then - tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] + tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] ..id.. [[" already exists as a xml:id. ]] .. @@ -644,8 +668,12 @@ function ekdosis.newhand(id, witid, siglum, description) 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) local indexwit = getindex(witid, listWit) - table.insert(listWit[indexwit].physDesc, {xmlid = id, head = siglum, description ={}}) + table.insert(listWit[indexwit].physDesc, {xmlid = id, + head = siglum, + handDesc = description}) end return true end @@ -655,16 +683,16 @@ function ekdosis.getsiglum(str, opt) str = string.gsub(str, "%s-(%,)", "%1") ctrl = str if opt == "tei" then - for i = 1,#listWit do - str = string.gsub(str, "(%f[%w])"..listWit[i].xmlid.."(%,)", "%1#"..listWit[i].xmlid.."%2") - ctrl = string.gsub(ctrl, listWit[i].xmlid.."%,", "") + for i = 1,#idsRend do + str = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)", "%1#"..idsRend[i].xmlid.."%2") + ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "") end str = string.gsub(str, "%,(%s-)([%#])", " %2") str = string.gsub(str, "%,$", "") else - for i = 1,#listWit do - str = string.gsub(str, listWit[i].xmlid.."%,", listWit[i].head) - ctrl = string.gsub(ctrl, listWit[i].xmlid.."%,", "") + for i = 1,#idsRend do + str = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].head) + ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "") end end if string.find(ctrl, "[A-Za-z0-9]") -- cgit v1.2.3