aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ekdosis.dtx32
1 files changed, 22 insertions, 10 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 91a5662..2245b8d 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -565,12 +565,24 @@ local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash)
565local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) 565local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
566local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) 566local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
567 567
568-- General
569xmlids = {}
570
571local function xmlidfound(element)
572 for i = 1,#xmlids do
573 if xmlids[i].xmlid == element then
574 return true
575 end
576 end
577 return false
578end
579
568-- Witnesses 580-- Witnesses
569listWit = {} 581listWit = {}
570 582
571local function isintable(table, element) 583local function isintable(table, value)
572 for i = 1,#table do 584 for i = 1,#table do
573 if table[i].a == element then 585 if table[i].a == value then
574 return true 586 return true
575 end 587 end
576 end 588 end
@@ -580,16 +592,17 @@ end
580local sorted_no = 0 592local sorted_no = 0
581 593
582function ekdosis.newwitness(id, siglum, description) 594function ekdosis.newwitness(id, siglum, description)
583 if isintable(listWit, id..",") 595 if xmlidfound(id)
584 then 596 then
585 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] 597 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
586 ..id.. 598 ..id..
587 [[" already exists as a witness id. ]] 599 [[" already exists as a xml:id. ]]
588 .. 600 ..
589 [[Please pick another id.}}]]) 601 [[Please pick another id.}}]])
590 else 602 else
591 sorted_no = sorted_no + 1 603 sorted_no = sorted_no + 1
592 id = id.."," 604 table.insert(xmlids, {xmlid = id})
605 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
593 table.insert(listWit, {a = id, b = siglum, c = description, d = sorted_no}) 606 table.insert(listWit, {a = id, b = siglum, c = description, d = sorted_no})
594 table.sort(listWit, function(a ,b) return(#a.a > #b.a) end) 607 table.sort(listWit, function(a ,b) return(#a.a > #b.a) end)
595 end 608 end
@@ -602,15 +615,15 @@ function ekdosis.getsiglum(str, opt)
602 ctrl = str 615 ctrl = str
603 if opt == "tei" then 616 if opt == "tei" then
604 for i = 1,#listWit do 617 for i = 1,#listWit do
605 str = string.gsub(str, "(%f[%w])"..listWit[i].a, "%1#"..listWit[i].a) 618 str = string.gsub(str, "(%f[%w])"..listWit[i].a.."(%,)", "%1#"..listWit[i].a.."%2")
606 ctrl = string.gsub(ctrl, listWit[i].a, "") 619 ctrl = string.gsub(ctrl, listWit[i].a.."%,", "")
607 end 620 end
608 str = string.gsub(str, "%,(%s-)([%#])", " %2") 621 str = string.gsub(str, "%,(%s-)([%#])", " %2")
609 str = string.gsub(str, "%,$", "") 622 str = string.gsub(str, "%,$", "")
610 else 623 else
611 for i = 1,#listWit do 624 for i = 1,#listWit do
612 str = string.gsub(str, listWit[i].a, listWit[i].b) 625 str = string.gsub(str, listWit[i].a.."%,", listWit[i].b)
613 ctrl = string.gsub(ctrl, listWit[i].a, "") 626 ctrl = string.gsub(ctrl, listWit[i].a.."%,", "")
614 end 627 end
615 end 628 end
616 if string.find(ctrl, "[A-Za-z0-9]") 629 if string.find(ctrl, "[A-Za-z0-9]")
@@ -648,7 +661,6 @@ function ekdosis.newcmdtotag(cmd, tag, attr)
648 return true 661 return true
649end 662end
650 663
651
652local function lem_rdg_totei(str) 664local function lem_rdg_totei(str)
653 str = gsub(str, dblbkslash * lemrdg * spcenc^-1 * bsqbrackets * bcbraces, 665 str = gsub(str, dblbkslash * lemrdg * spcenc^-1 * bsqbrackets * bcbraces,
654 function(bkslash, cmd, opt, arg) 666 function(bkslash, cmd, opt, arg)