aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-04-21 19:24:57 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-04-21 19:24:57 +0200
commit9f476bf2b9667427de8968f7e7db4fd97f7ffa01 (patch)
tree74823e0434b498ae669685cf6cf5af66461fd96d
parent10a48a2cfa89285e5f1648d1241fe1019d0d56a2 (diff)
downloadekdosis-9f476bf2b9667427de8968f7e7db4fd97f7ffa01.tar.gz
new function \DeclareNewShorthand. replaced head with abbr in TEI header
-rw-r--r--ekdosis.dtx47
1 files changed, 37 insertions, 10 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 8a6cbb7..fdf582f 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -404,6 +404,12 @@ idno={}, msName={}, origDate={}][3]{%
404 \luastringN{#2})} 404 \luastringN{#2})}
405} 405}
406\@onlypreamble\DeclareNewScholar 406\@onlypreamble\DeclareNewScholar
407\NewDocumentCommand{\DeclareNewShorthand}{m m m}{
408 \luadirect{ekdosis.newshorthand(\luastringN{#1},
409 \luastringN{#2},
410 \luastringN{#3})}
411}
412\@onlypreamble\DeclareNewShorthand
407\NewDocumentCommand{\getsiglum}{m}{% 413\NewDocumentCommand{\getsiglum}{m}{%
408 \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}% 414 \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))}%
409} 415}
@@ -672,6 +678,7 @@ end
672-- Witnesses 678-- Witnesses
673listWit = {} 679listWit = {}
674idsRend = {} 680idsRend = {}
681shorthands = {}
675 682
676local function isintable(table, value) 683local function isintable(table, value)
677 for i = 1,#table do 684 for i = 1,#table do
@@ -712,10 +719,10 @@ function ekdosis.newwitness(id,
712 else 719 else
713 table.insert(xmlids, {xmlid = id}) 720 table.insert(xmlids, {xmlid = id})
714 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) 721 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
715 table.insert(idsRend, {xmlid = id, head = siglum}) 722 table.insert(idsRend, {xmlid = id, abbr = siglum})
716 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end) 723 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
717 table.insert(listWit, {xmlid = id, 724 table.insert(listWit, {xmlid = id,
718 head = siglum, 725 abbr = siglum,
719 msIdentifier = { 726 msIdentifier = {
720 settlement = Settlement, 727 settlement = Settlement,
721 repository = Repository, 728 repository = Repository,
@@ -743,16 +750,33 @@ function ekdosis.newhand(id, witid, siglum, description)
743 else 750 else
744 table.insert(xmlids, {xmlid = id}) 751 table.insert(xmlids, {xmlid = id})
745 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) 752 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
746 table.insert(idsRend, {xmlid = id, head = siglum}) 753 table.insert(idsRend, {xmlid = id, abbr = siglum})
747 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end) 754 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
748 local indexwit = getindex(witid, listWit) 755 local indexwit = getindex(witid, listWit)
749 -- listWit[indexwit].handDesc = {xmlid = id, head = siglum, handNote = description} 756 -- listWit[indexwit].handDesc = {xmlid = id, abbr = siglum, handNote = description}
750 if listWit[indexwit].handDesc == nil 757 if listWit[indexwit].handDesc == nil
751 then 758 then
752 listWit[indexwit].handDesc = {} 759 listWit[indexwit].handDesc = {}
753 else 760 else
754 end 761 end
755 table.insert(listWit[indexwit].handDesc, {xmlid = id, head = siglum, handNote = description}) 762 table.insert(listWit[indexwit].handDesc, {xmlid = id, abbr = siglum, handNote = description})
763 end
764 return true
765end
766
767function ekdosis.newshorthand(id, rend, xmlids)
768 if isintable(shorthands, id)
769 then
770 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
771 ..id..
772 [[" already exists as a shorthand. ]]
773 ..
774 [[Please pick another shorthand.}}]])
775 else
776 table.insert(shorthands, { a = id, b = rend, c = xmlids })
777 table.sort(shorthands, function(a ,b) return(#a.a > #b.a) end)
778 table.insert(idsRend, {xmlid = id, abbr = rend})
779 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
756 end 780 end
757 return true 781 return true
758end 782end
@@ -775,7 +799,7 @@ function ekdosis.newscholar(id, siglum)
775 else 799 else
776 table.insert(xmlids, {xmlid = id}) 800 table.insert(xmlids, {xmlid = id})
777 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) 801 table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end)
778 table.insert(idsRend, {xmlid = id, head = siglum}) 802 table.insert(idsRend, {xmlid = id, abbr = siglum})
779 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end) 803 table.sort(idsRend, function(a ,b) return(#a.xmlid > #b.xmlid) end)
780 end 804 end
781 return true 805 return true
@@ -786,6 +810,9 @@ function ekdosis.getsiglum(str, opt)
786 str = string.gsub(str, "%s-(%,)", "%1") 810 str = string.gsub(str, "%s-(%,)", "%1")
787 ctrl = str 811 ctrl = str
788 if opt == "tei" then 812 if opt == "tei" then
813 for i = 1,#shorthands do
814 str = string.gsub(str, shorthands[i].a, shorthands[i].c)
815 end
789 for i = 1,#idsRend do 816 for i = 1,#idsRend do
790 str = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)", "%1#"..idsRend[i].xmlid.."%2") 817 str = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)", "%1#"..idsRend[i].xmlid.."%2")
791 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "") 818 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
@@ -794,7 +821,7 @@ function ekdosis.getsiglum(str, opt)
794 str = string.gsub(str, "%,$", "") 821 str = string.gsub(str, "%,$", "")
795 else 822 else
796 for i = 1,#idsRend do 823 for i = 1,#idsRend do
797 str = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].head) 824 str = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].abbr)
798 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "") 825 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
799 end 826 end
800 end 827 end
@@ -918,7 +945,7 @@ function ekdosis.openteistream()
918 f:write("<listWit>", "\n") 945 f:write("<listWit>", "\n")
919 for i = 1,#listWit do 946 for i = 1,#listWit do
920 f:write("<msDesc xml:id=\"", listWit[i].xmlid, "\">", "\n") 947 f:write("<msDesc xml:id=\"", listWit[i].xmlid, "\">", "\n")
921 f:write("<head>", ekdosis.textotei(listWit[i].head), "</head>", "\n") 948 f:write("<abbr>", ekdosis.textotei(listWit[i].abbr), "</abbr>", "\n")
922 if listWit[i].msIdentifier.settlement == "" 949 if listWit[i].msIdentifier.settlement == ""
923 and listWit[i].msIdentifier.repository == "" 950 and listWit[i].msIdentifier.repository == ""
924 and listWit[i].msIdentifier.idno == "" 951 and listWit[i].msIdentifier.idno == ""
@@ -947,7 +974,7 @@ function ekdosis.openteistream()
947 while listWit[i].handDesc[j] 974 while listWit[i].handDesc[j]
948 do 975 do
949 f:write("<handDesc xml:id=\"", listWit[i].handDesc[j].xmlid, "\">", "\n") 976 f:write("<handDesc xml:id=\"", listWit[i].handDesc[j].xmlid, "\">", "\n")
950 f:write("<head>", ekdosis.textotei(listWit[i].handDesc[j].head), "</head>", "\n") 977 f:write("<abbr>", ekdosis.textotei(listWit[i].handDesc[j].abbr), "</abbr>", "\n")
951 if listWit[i].handDesc[j].handNote == "" then else 978 if listWit[i].handDesc[j].handNote == "" then else
952 f:write("<handNote>\n<p>", ekdosis.textotei(listWit[i].handDesc[j].handNote), "</p>\n</handNote>", "\n") 979 f:write("<handNote>\n<p>", ekdosis.textotei(listWit[i].handDesc[j].handNote), "</p>\n</handNote>", "\n")
953 end 980 end
@@ -1022,7 +1049,7 @@ end
1022-- begin basic TeX Conspectus siglorum 1049-- begin basic TeX Conspectus siglorum
1023function ekdosis.basic_cs(msid) 1050function ekdosis.basic_cs(msid)
1024 local indexwit = getindex(msid, listWit) 1051 local indexwit = getindex(msid, listWit)
1025 siglum = listWit[indexwit].head 1052 siglum = listWit[indexwit].abbr
1026 if listWit[indexwit].detailsDesc == "" 1053 if listWit[indexwit].detailsDesc == ""
1027 then 1054 then
1028 name = listWit[indexwit].msIdentifier.msName 1055 name = listWit[indexwit].msIdentifier.msName