aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ekdosis.dtx115
1 files changed, 103 insertions, 12 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 3f50def..c85aec8 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -5400,6 +5400,13 @@ local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter")
5400local par = lpeg.P(lpeg.P("\\par") * spce^1) 5400local par = lpeg.P(lpeg.P("\\par") * spce^1)
5401local parb = lpeg.P(lpeg.Cs("\\p@rb") * spce^1) 5401local parb = lpeg.P(lpeg.Cs("\\p@rb") * spce^1)
5402local para = lpeg.P(lpeg.Cs("\\p@ra") * spce^1) 5402local para = lpeg.P(lpeg.Cs("\\p@ra") * spce^1)
5403local labelrefcmds = lpeg.Cs(lpeg.P("label")
5404 + lpeg.P("linelabel")
5405 + lpeg.P("lineref")
5406 + lpeg.P("ref")
5407 + lpeg.P("pageref")
5408 + lpeg.P("vref")
5409 + lpeg.P("vpageref"))
5403 5410
5404-- Bind to local variables 5411-- Bind to local variables
5405local next = next 5412local next = next
@@ -5494,7 +5501,7 @@ function ekdosis.newwitness(id,
5494 then 5501 then
5495 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" 5502 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
5496 ..id.. 5503 ..id..
5497 "\" is not a valid xml:id. " 5504 "\" is not a valid xml:id. \\MessageBreak "
5498 .. 5505 ..
5499 "Please pick another id.}}") 5506 "Please pick another id.}}")
5500 else 5507 else
@@ -5534,7 +5541,7 @@ function ekdosis.newhand(id, witid, siglum, description)
5534 then 5541 then
5535 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" 5542 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
5536 ..id.. 5543 ..id..
5537 "\" is not a valid xml:id. " 5544 "\" is not a valid xml:id. \\MessageBreak "
5538 .. 5545 ..
5539 "Please pick another id.}}") 5546 "Please pick another id.}}")
5540 else 5547 else
@@ -5591,7 +5598,7 @@ function ekdosis.newscholar(id, siglum)
5591 then 5598 then
5592 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" 5599 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
5593 ..id.. 5600 ..id..
5594 "\" is not a valid xml:id. " 5601 "\" is not a valid xml:id. \\MessageBreak "
5595 .. 5602 ..
5596 "Please pick another id.}}") 5603 "Please pick another id.}}")
5597 else 5604 else
@@ -5656,13 +5663,13 @@ local cmdtotags = {
5656 5663
5657local texpatttotags = { 5664local texpatttotags = {
5658 {a="\\altrfont%s+", b=""}, 5665 {a="\\altrfont%s+", b=""},
5659 {a="\\icite%s?%[(.-)%]%[(.-)%]{(.-)}", b="%1 <ref target=\"#%3\">%2</ref>"}, 5666 -- {a="\\icite%s?%[(.-)%]%[(.-)%]{(.-)}", b="%1 <ref target=\"#%3\">%2</ref>"},
5660 {a="\\icite%s?%[(.-)%]{(.-)}", b="<ref target=\"#%2\">%1</ref>"}, 5667 -- {a="\\icite%s?%[(.-)%]{(.-)}", b="<ref target=\"#%2\">%1</ref>"},
5661 {a="\\icite%s?{(.-)}", b="<ptr target=\"#%1\"/>"}, 5668 -- {a="\\icite%s?{(.-)}", b="<ptr target=\"#%1\"/>"},
5662 {a="\\linelabel%s?{(.-)}", b="<anchor xml:id=\"%1\"/>"}, 5669 -- {a="\\linelabel%s?{(.-)}", b="<anchor xml:id=\"%1\"/>"},
5663 {a="\\label%s?{(.-)}", b="<anchor xml:id=\"%1\"/>"}, 5670 -- {a="\\label%s?{(.-)}", b="<anchor xml:id=\"%1\"/>"},
5664 {a="\\v?pageref%s?{(.-)}", b="<ptr target=\"#%1\"/>"}, 5671 -- {a="\\v?pageref%s?{(.-)}", b="<ptr target=\"#%1\"/>"},
5665 {a="\\v?ref%s?{(.-)}", b="<ptr target=\"#%1\"/>"}, 5672 -- {a="\\v?ref%s?{(.-)}", b="<ptr target=\"#%1\"/>"},
5666 {a="\\LR%s+{(.-)}", b="%1"}, 5673 {a="\\LR%s+{(.-)}", b="%1"},
5667 {a="\\RL%s+{(.-)}", b="%1"} 5674 {a="\\RL%s+{(.-)}", b="%1"}
5668} 5675}
@@ -5928,6 +5935,70 @@ local function texpatttotei(str)
5928 return str 5935 return str
5929end 5936end
5930 5937
5938local function icitetotei(str)
5939 str = gsub(str, lpeg.P("\\")
5940 * lpeg.Cs("icite")
5941 * spcenc^-1
5942 * bsqbrackets
5943 * bsqbrackets
5944 * bcbraces
5945 * bsqbrackets^-1,
5946 function(cmd, pre, post, body, opt)
5947 pre = string.sub(pre, 2, -2)
5948 post = string.sub(post, 2, -2)
5949 body = string.sub(body, 2, -2)
5950 if not checkxmlid(body)
5951 then
5952 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
5953 ..body..
5954 "\" is not a valid xml:id. \\MessageBreak "
5955 ..
5956 "Please pick another id.}}")
5957 else
5958 end
5959 return string.format("%s <ref target=\"#%s\">%s</ref>", pre, body, post)
5960 end)
5961 str = gsub(str, lpeg.P("\\")
5962 * lpeg.Cs("icite")
5963 * spcenc^-1
5964 * bsqbrackets
5965 * bcbraces
5966 * bsqbrackets^-1,
5967 function(cmd, post, body, opt)
5968 post = string.sub(post, 2, -2)
5969 body = string.sub(body, 2, -2)
5970 if not checkxmlid(body)
5971 then
5972 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
5973 ..body..
5974 "\" is not a valid xml:id. \\MessageBreak "
5975 ..
5976 "Please pick another id.}}")
5977 else
5978 end
5979 return string.format("<ref target=\"#%s\">%s</ref>", body, post)
5980 end)
5981 str = gsub(str, lpeg.P("\\")
5982 * lpeg.Cs("icite")
5983 * spcenc^-1
5984 * bcbraces
5985 * bsqbrackets^-1,
5986 function(cmd, body, opt)
5987 body = string.sub(body, 2, -2)
5988 if not checkxmlid(body)
5989 then
5990 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
5991 ..body..
5992 "\" is not a valid xml:id. \\MessageBreak "
5993 ..
5994 "Please pick another id.}}")
5995 else
5996 end
5997 return string.format("<ptr target=\"#%s\"/>", body)
5998 end)
5999 return str
6000end
6001
5931local function cmdtotei(str) 6002local function cmdtotei(str)
5932 for i = 1,#cmdtotags 6003 for i = 1,#cmdtotags
5933 do 6004 do
@@ -5963,6 +6034,25 @@ local function cmdtotei(str)
5963 return string.format("<ref target=\"%s\">%s</ref>", 6034 return string.format("<ref target=\"%s\">%s</ref>",
5964 teisiglum, printsiglum) 6035 teisiglum, printsiglum)
5965 end) 6036 end)
6037 str = gsub(str, lpeg.P("\\") * labelrefcmds * spcenc^-1 * bcbraces,
6038 function(cmd, body)
6039 body = string.sub(body, 2, -2)
6040 if not checkxmlid(body)
6041 then
6042 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
6043 ..body..
6044 "\" is not a valid xml:id. \\MessageBreak "
6045 ..
6046 "Please pick another id.}}")
6047 else
6048 end
6049 if string.find(cmd, "label")
6050 then
6051 return string.format("<anchor xml:id=\"%s\"/>", body)
6052 else
6053 return string.format("<ptr target=\"#%s\"/>", body)
6054 end
6055 end)
5966 str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})", 6056 str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})",
5967 function(cmd, opt, body) 6057 function(cmd, opt, body)
5968 body = string.sub(body, 2, -2) 6058 body = string.sub(body, 2, -2)
@@ -6296,6 +6386,7 @@ local function textotei(str)
6296 str = envtotei(str) 6386 str = envtotei(str)
6297 str = ekddivs_totei(str) 6387 str = ekddivs_totei(str)
6298 str = section_totei(str) 6388 str = section_totei(str)
6389 str = icitetotei(str)
6299 str = cmdtotei(str) 6390 str = cmdtotei(str)
6300 str = self_close_tags(str) 6391 str = self_close_tags(str)
6301 str = partotei(str) 6392 str = partotei(str)
@@ -6654,7 +6745,7 @@ function ekdosis.newscholar(id, siglum)
6654 then 6745 then
6655 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" 6746 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
6656 ..id.. 6747 ..id..
6657 "\" is not a valid xml:id. " 6748 "\" is not a valid xml:id. \\MessageBreak "
6658 .. 6749 ..
6659 "Please pick another id.}}") 6750 "Please pick another id.}}")
6660 else 6751 else
@@ -6687,7 +6778,7 @@ local function build_envdiv(str)
6687 then 6778 then
6688 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" 6779 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
6689 ..div.. 6780 ..div..
6690 "\" is not a valid xml:id. " 6781 "\" is not a valid xml:id. \\MessageBreak "
6691 .. 6782 ..
6692 "Please pick another id.}}") 6783 "Please pick another id.}}")
6693 else 6784 else