aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-03-31 22:33:05 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-03-31 22:33:05 +0200
commitdc7c60c90a10154ed0870caf3f6b9bee4add29f4 (patch)
treea7dce4145f05885332424e73ff76c9085f433f7a /ekdosis.dtx
parentf2f5e3da4b29712e1dfda69583e7a669008b3772 (diff)
downloadekdosis-dc7c60c90a10154ed0870caf3f6b9bee4add29f4.tar.gz
working on \DeclareNewWitness
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r--ekdosis.dtx76
1 files 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.
354% \end{macrocode} 354% \end{macrocode}
355% Build and process the list of witnesses and hands 355% Build and process the list of witnesses and hands
356% \begin{macrocode} 356% \begin{macrocode}
357\NewDocumentCommand{\DeclareNewWitness}{m m +m}{ 357% \NewDocumentCommand{\DeclareNewWitness}{m m +m}{
358 \luadirect{ekdosis.newwitness(\luastringN{#1}, 358% \luadirect{ekdosis.newwitness(\luastringN{#1},
359 \luastringN{#2}, 359% \luastringN{#2},
360 \luastringN{#3})} 360% \luastringN{#3})}
361% }
362\newkeycommand+[\|]{\declare@new@witness}[settlement={}, repository={},
363idno={}, msName={}][3]{%
364 |\luadirect|{%
365 ekdosis.newwitness(
366 |\luastringN|{#1},
367 |\luastringN|{#2},
368 |\luastringN|{#3},
369 |\luastringN|{\commandkey{settlement}},
370 |\luastringN|{\commandkey{repository}},
371 |\luastringN|{\commandkey{idno}},
372 |\luastringN|{\commandkey{msName}})}
373}
374\NewDocumentCommand{\DeclareNewWitness}{m m O{} +m}{%
375 \declare@new@witness[#3]{#1}{#2}{#4}
361} 376}
362\NewDocumentCommand{\DeclareNewHand}{m m m +m}{ 377\NewDocumentCommand{\DeclareNewHand}{m m m +m}{
363 \luadirect{ekdosis.newhand(\luastringN{#1}, 378 \luadirect{ekdosis.newhand(\luastringN{#1},
@@ -470,10 +485,11 @@ choice nolem={false,,true}][1]{%
470% \define@key[ekd]{lemma}{wit}{\getsiglum{#1}} 485% \define@key[ekd]{lemma}{wit}{\getsiglum{#1}}
471% \define@key[ekd]{lemma}{tchic}{#1} 486% \define@key[ekd]{lemma}{tchic}{#1}
472% \presetkeys[ekd]{lemma}{wit={},tchic={}}{} 487% \presetkeys[ekd]{lemma}{wit={},tchic={}}{}
473% \def\mgetsiglum#1{\setkeys[ekd]{lemma}[tchic]{#1}} 488% \def\m@getsiglum#1{\setkeys[ekd]{lemma}[tchic]{#1}}
474% \def\mtchic#1{\setkeys[ekd]{lemma}[wit]{#1}} 489% \def\mtchic#1{\setkeys[ekd]{lemma}[wit]{#1}}
475% \NewDocumentCommand{\mrdg}{O{} +m}{% 490% \NewDocumentCommand{\mrdg}{O{} +m}{%
476% \append@app{#2 \mtchic{#1}\mgetsiglum{#1}\mtchic{#1}}% 491% \setkeys[ekd]{lemma}[tchic]{#1}
492% \append@app{#2 \csname m@getsiglum\endcsname{#1}}%
477% } 493% }
478\newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit][1]{% 494\newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit][1]{%
479 |\ifbool{al@rlmode}|% 495 |\ifbool{al@rlmode}|%
@@ -596,8 +612,6 @@ local function isintable(table, value)
596 return false 612 return false
597end 613end
598 614
599local sorted_no = 0
600
601local function getindex(id, table) 615local function getindex(id, table)
602 local idfound = nil 616 local idfound = nil
603 for i = 1,#table 617 for i = 1,#table
@@ -610,33 +624,43 @@ local function getindex(id, table)
610 return idfound 624 return idfound
611end 625end
612 626
613function ekdosis.newwitness(id, siglum, description) 627function ekdosis.newwitness(id,
628 siglum,
629 description,
630 Settlement,
631 Repository,
632 Idno,
633 MsName)
614 if xmlidfound(id) 634 if xmlidfound(id)
615 then 635 then
616 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] 636 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
617 ..id.. 637 ..id..
618 [[" already exists as a xml:id. ]] 638 [[" already exists as a xml:id. ]]
619 .. 639 ..
620 [[Please pick another id.}}]]) 640 [[Please pick another id.}}]])
621 else 641 else
622 sorted_no = sorted_no + 1
623 table.insert(xmlids, {xmlid = id}) 642 table.insert(xmlids, {xmlid = id})
624 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) 643 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
644 table.insert(idsRend, {xmlid = id, head = siglum})
645 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
625 table.insert(listWit, {xmlid = id, 646 table.insert(listWit, {xmlid = id,
626 head = siglum, 647 head = siglum,
627 msIdentifier = {}, 648 msIdentifier = {
649 settlement = Settlement,
650 repository = Repository,
651 idno = Idno,
652 msName = MsName
653 },
628 physDesc = {}, 654 physDesc = {},
629 description = {}, 655 detailsDesc = description})
630 sorted = sorted_no})
631 table.sort(listWit, function(a ,b) return(#a.xmlid > #b.xmlid) end)
632 end 656 end
633 return true 657 return true
634end 658end
635 659
636function ekdosis.newhand(id, witid, siglum, description) 660function ekdosis.newhand(id, witid, siglum, description)
637 if xmlidfound(id) 661 if xmlidfound(id) or not xmlidfound(witid)
638 then 662 then
639 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] 663 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
640 ..id.. 664 ..id..
641 [[" already exists as a xml:id. ]] 665 [[" already exists as a xml:id. ]]
642 .. 666 ..
@@ -644,8 +668,12 @@ function ekdosis.newhand(id, witid, siglum, description)
644 else 668 else
645 table.insert(xmlids, {xmlid = id}) 669 table.insert(xmlids, {xmlid = id})
646 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) 670 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
671 table.insert(idsRend, {xmlid = id, head = siglum})
672 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
647 local indexwit = getindex(witid, listWit) 673 local indexwit = getindex(witid, listWit)
648 table.insert(listWit[indexwit].physDesc, {xmlid = id, head = siglum, description ={}}) 674 table.insert(listWit[indexwit].physDesc, {xmlid = id,
675 head = siglum,
676 handDesc = description})
649 end 677 end
650 return true 678 return true
651end 679end
@@ -655,16 +683,16 @@ function ekdosis.getsiglum(str, opt)
655 str = string.gsub(str, "%s-(%,)", "%1") 683 str = string.gsub(str, "%s-(%,)", "%1")
656 ctrl = str 684 ctrl = str
657 if opt == "tei" then 685 if opt == "tei" then
658 for i = 1,#listWit do 686 for i = 1,#idsRend do
659 str = string.gsub(str, "(%f[%w])"..listWit[i].xmlid.."(%,)", "%1#"..listWit[i].xmlid.."%2") 687 str = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)", "%1#"..idsRend[i].xmlid.."%2")
660 ctrl = string.gsub(ctrl, listWit[i].xmlid.."%,", "") 688 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
661 end 689 end
662 str = string.gsub(str, "%,(%s-)([%#])", " %2") 690 str = string.gsub(str, "%,(%s-)([%#])", " %2")
663 str = string.gsub(str, "%,$", "") 691 str = string.gsub(str, "%,$", "")
664 else 692 else
665 for i = 1,#listWit do 693 for i = 1,#idsRend do
666 str = string.gsub(str, listWit[i].xmlid.."%,", listWit[i].head) 694 str = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].head)
667 ctrl = string.gsub(ctrl, listWit[i].xmlid.."%,", "") 695 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
668 end 696 end
669 end 697 end
670 if string.find(ctrl, "[A-Za-z0-9]") 698 if string.find(ctrl, "[A-Za-z0-9]")