aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-03-30 21:48:21 +0100
committerRobert Alessi <alessi@robertalessi.net>2019-03-30 21:48:21 +0100
commitf2f5e3da4b29712e1dfda69583e7a669008b3772 (patch)
tree565382505bdcb1b29f9e2cd865d27b1c5219e9be /ekdosis.dtx
parent9ffbfd44c97186e74157f1d09d64d21816d1b2ad (diff)
downloadekdosis-f2f5e3da4b29712e1dfda69583e7a669008b3772.tar.gz
declare new hands
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r--ekdosis.dtx55
1 files changed, 48 insertions, 7 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 2245b8d..1328c4e 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -352,13 +352,19 @@ Running "make install" installs the files in the local TeX tree.
352 \luadirect{ekdosis.closeteistream()} 352 \luadirect{ekdosis.closeteistream()}
353} 353}
354% \end{macrocode} 354% \end{macrocode}
355% Build an process the list of witnesses 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} 361}
362\NewDocumentCommand{\DeclareNewHand}{m m m +m}{
363 \luadirect{ekdosis.newhand(\luastringN{#1},
364 \luastringN{#2},
365 \luastringN{#3},
366 \luastringN{#4})}
367}
362\NewDocumentCommand{\getsiglum}{m}{% 368\NewDocumentCommand{\getsiglum}{m}{%
363 \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}% 369 \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}%
364} 370}
@@ -579,6 +585,7 @@ end
579 585
580-- Witnesses 586-- Witnesses
581listWit = {} 587listWit = {}
588idsRend = {}
582 589
583local function isintable(table, value) 590local function isintable(table, value)
584 for i = 1,#table do 591 for i = 1,#table do
@@ -590,6 +597,18 @@ local function isintable(table, value)
590end 597end
591 598
592local sorted_no = 0 599local sorted_no = 0
600
601local function getindex(id, table)
602 local idfound = nil
603 for i = 1,#table
604 do
605 if table[i].xmlid == id then
606 idfound = i
607 break
608 end
609 end
610 return idfound
611end
593 612
594function ekdosis.newwitness(id, siglum, description) 613function ekdosis.newwitness(id, siglum, description)
595 if xmlidfound(id) 614 if xmlidfound(id)
@@ -603,8 +622,30 @@ function ekdosis.newwitness(id, siglum, description)
603 sorted_no = sorted_no + 1 622 sorted_no = sorted_no + 1
604 table.insert(xmlids, {xmlid = id}) 623 table.insert(xmlids, {xmlid = id})
605 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) 624 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
606 table.insert(listWit, {a = id, b = siglum, c = description, d = sorted_no}) 625 table.insert(listWit, {xmlid = id,
607 table.sort(listWit, function(a ,b) return(#a.a > #b.a) end) 626 head = siglum,
627 msIdentifier = {},
628 physDesc = {},
629 description = {},
630 sorted = sorted_no})
631 table.sort(listWit, function(a ,b) return(#a.xmlid > #b.xmlid) end)
632 end
633 return true
634end
635
636function ekdosis.newhand(id, witid, siglum, description)
637 if xmlidfound(id)
638 then
639 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
640 ..id..
641 [[" already exists as a xml:id. ]]
642 ..
643 [[Please pick another id.}}]])
644 else
645 table.insert(xmlids, {xmlid = id})
646 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
647 local indexwit = getindex(witid, listWit)
648 table.insert(listWit[indexwit].physDesc, {xmlid = id, head = siglum, description ={}})
608 end 649 end
609 return true 650 return true
610end 651end
@@ -615,15 +656,15 @@ function ekdosis.getsiglum(str, opt)
615 ctrl = str 656 ctrl = str
616 if opt == "tei" then 657 if opt == "tei" then
617 for i = 1,#listWit do 658 for i = 1,#listWit do
618 str = string.gsub(str, "(%f[%w])"..listWit[i].a.."(%,)", "%1#"..listWit[i].a.."%2") 659 str = string.gsub(str, "(%f[%w])"..listWit[i].xmlid.."(%,)", "%1#"..listWit[i].xmlid.."%2")
619 ctrl = string.gsub(ctrl, listWit[i].a.."%,", "") 660 ctrl = string.gsub(ctrl, listWit[i].xmlid.."%,", "")
620 end 661 end
621 str = string.gsub(str, "%,(%s-)([%#])", " %2") 662 str = string.gsub(str, "%,(%s-)([%#])", " %2")
622 str = string.gsub(str, "%,$", "") 663 str = string.gsub(str, "%,$", "")
623 else 664 else
624 for i = 1,#listWit do 665 for i = 1,#listWit do
625 str = string.gsub(str, listWit[i].a.."%,", listWit[i].b) 666 str = string.gsub(str, listWit[i].xmlid.."%,", listWit[i].head)
626 ctrl = string.gsub(ctrl, listWit[i].a.."%,", "") 667 ctrl = string.gsub(ctrl, listWit[i].xmlid.."%,", "")
627 end 668 end
628 end 669 end
629 if string.find(ctrl, "[A-Za-z0-9]") 670 if string.find(ctrl, "[A-Za-z0-9]")