diff options
-rw-r--r-- | ekdosis.dtx | 78 |
1 files changed, 57 insertions, 21 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index ad26fc9..c4a706f 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -134,6 +134,7 @@ Running "make install" installs the files in the local TeX tree. | |||
134 | \documentclass{ltxdoc} | 134 | \documentclass{ltxdoc} |
135 | \usepackage[letterpaper,margin=25mm,left=50mm,nohead]{geometry} | 135 | \usepackage[letterpaper,margin=25mm,left=50mm,nohead]{geometry} |
136 | \usepackage{metalogox} | 136 | \usepackage{metalogox} |
137 | \usepackage{hologo} | ||
137 | \usepackage{hyperxmp} | 138 | \usepackage{hyperxmp} |
138 | \usepackage{uri} | 139 | \usepackage{uri} |
139 | \usepackage[numbered]{hypdoc} | 140 | \usepackage[numbered]{hypdoc} |
@@ -162,7 +163,7 @@ Running "make install" installs the files in the local TeX tree. | |||
162 | \usepackage{units} | 163 | \usepackage{units} |
163 | \usepackage[newfloat=true]{minted} | 164 | \usepackage[newfloat=true]{minted} |
164 | \newminted[ekdlua]{lua}{linenos, fontsize=\relsize{-0.5}, | 165 | \newminted[ekdlua]{lua}{linenos, fontsize=\relsize{-0.5}, |
165 | xleftmargin=12pt, | 166 | xleftmargin=12pt, breaklines, |
166 | numberblanklines=false, numbersep=3pt, firstnumber=last} | 167 | numberblanklines=false, numbersep=3pt, firstnumber=last} |
167 | \renewcommand{\theFancyVerbLine}{\rmfamily\smaller\arabic{FancyVerbLine}} | 168 | \renewcommand{\theFancyVerbLine}{\rmfamily\smaller\arabic{FancyVerbLine}} |
168 | \usepackage[contents]{colordoc} | 169 | \usepackage[contents]{colordoc} |
@@ -362,6 +363,14 @@ Running "make install" installs the files in the local TeX tree. | |||
362 | \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))} | 363 | \luadirect{tex.sprint(ekdosis.getsiglum(\luastringN{#1}))} |
363 | } | 364 | } |
364 | % \end{macrocode} | 365 | % \end{macrocode} |
366 | % Add a \hologo{(La)TeX} command to be processed as a |TEI xml| tag: | ||
367 | % \begin{macrocode} | ||
368 | \NewDocumentCommand{\TeXtoTEI}{m m m}{% | ||
369 | \luadirect{ekdosis.newcmdtotag(\luastringN{#1}, | ||
370 | \luastringN{#2}, | ||
371 | \luastringN{#3})} | ||
372 | } | ||
373 | % \end{macrocode} | ||
365 | % \begin{macrocode} | 374 | % \begin{macrocode} |
366 | \newbool{ekd@started} | 375 | \newbool{ekd@started} |
367 | \newbool{do@app} | 376 | \newbool{do@app} |
@@ -548,16 +557,10 @@ local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash) | |||
548 | local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) | 557 | local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) |
549 | local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) | 558 | local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg")) |
550 | 559 | ||
560 | -- Witnesses | ||
551 | listWit = {} | 561 | listWit = {} |
552 | 562 | ||
553 | function ekdosis.newwitness(id, siglum, description) | 563 | local function isintable(table, element) |
554 | id = id.."," | ||
555 | table.insert(listWit, {a = id, b = siglum, c = description}) | ||
556 | table.sort(listWit, function(a ,b) return(#a.a > #b.a) end) | ||
557 | return true | ||
558 | end | ||
559 | |||
560 | function ekdosis.isintable(table, element) | ||
561 | for i = 1,#table do | 564 | for i = 1,#table do |
562 | if table[i].a == element then | 565 | if table[i].a == element then |
563 | return true | 566 | return true |
@@ -566,13 +569,32 @@ function ekdosis.isintable(table, element) | |||
566 | return false | 569 | return false |
567 | end | 570 | end |
568 | 571 | ||
572 | local sorted_no = 0 | ||
573 | |||
574 | function ekdosis.newwitness(id, siglum, description) | ||
575 | if isintable(listWit, id..",") | ||
576 | then | ||
577 | tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] | ||
578 | ..id.. | ||
579 | [[" already exists as a witness id. ]] | ||
580 | .. | ||
581 | [[Please pick another id.}}]]) | ||
582 | else | ||
583 | sorted_no = sorted_no + 1 | ||
584 | id = id.."," | ||
585 | table.insert(listWit, {a = id, b = siglum, c = description, d = sorted_no}) | ||
586 | table.sort(listWit, function(a ,b) return(#a.a > #b.a) end) | ||
587 | end | ||
588 | return true | ||
589 | end | ||
590 | |||
569 | function ekdosis.getsiglum(str, opt) | 591 | function ekdosis.getsiglum(str, opt) |
570 | str = str.."," | 592 | str = str.."," |
571 | str = string.gsub(str, "%s-(%,)", "%1") | 593 | str = string.gsub(str, "%s-(%,)", "%1") |
572 | ctrl = str | 594 | ctrl = str |
573 | if opt == "tei" then | 595 | if opt == "tei" then |
574 | for i = 1,#listWit do | 596 | for i = 1,#listWit do |
575 | str = string.gsub(str, listWit[i].a, "#"..listWit[i].a) | 597 | str = string.gsub(str, "(%f[%w])"..listWit[i].a, "%1#"..listWit[i].a) |
576 | ctrl = string.gsub(ctrl, listWit[i].a, "") | 598 | ctrl = string.gsub(ctrl, listWit[i].a, "") |
577 | end | 599 | end |
578 | str = string.gsub(str, "%,(%s-)([%#])", " %2") | 600 | str = string.gsub(str, "%,(%s-)([%#])", " %2") |
@@ -592,19 +614,33 @@ function ekdosis.getsiglum(str, opt) | |||
592 | end | 614 | end |
593 | 615 | ||
594 | -- begin totei functions | 616 | -- begin totei functions |
595 | local tags = { | 617 | local cmdtotags = { |
596 | {a="footnote", b="note", c=" pos=\"foot\""}, | 618 | {a="footnote", b="note", c=" place=\"bottom\""}, |
597 | {a="textbf", b="hi", c=" rend=\"bold\""}, | 619 | {a="textbf", b="hi", c=" rend=\"bold\""}, |
598 | {a="emph", b="hi", c=" rend=\"italic\""}, | ||
599 | {a="textsf", b="hi", c=" rend=\"sans\""}, | ||
600 | {a="txarb", b="foreign", c=" xml:lang=\"arb\""}, | 620 | {a="txarb", b="foreign", c=" xml:lang=\"arb\""}, |
621 | {a="emph", b="hi", c=" rend=\"italic\""}, | ||
601 | {a="arb", b="foreign", c=" xml:lang=\"arb\""}, | 622 | {a="arb", b="foreign", c=" xml:lang=\"arb\""}, |
602 | {a="sg", b="foreign", c=" xml:lang=\"grc\""}, | ||
603 | {a="app", b="app", c=""}, | 623 | {a="app", b="app", c=""}, |
604 | {a="lem", b="lem", c=""}, | 624 | {a="lem", b="lem", c=""}, |
605 | {a="rdg", b="rdg", c=""} | 625 | {a="rdg", b="rdg", c=""} |
606 | } | 626 | } |
607 | 627 | ||
628 | function ekdosis.newcmdtotag(cmd, tag, attr) | ||
629 | if isintable(cmdtotags, cmd) | ||
630 | then | ||
631 | tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] | ||
632 | ..cmd.. | ||
633 | [[" already exists as a known command to be processed to TEI. ]] | ||
634 | .. | ||
635 | [[Please pick another command.}}]]) | ||
636 | else | ||
637 | table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr}) | ||
638 | table.sort(cmdtotags, function(a ,b) return(#a.a > #b.a) end) | ||
639 | end | ||
640 | return true | ||
641 | end | ||
642 | |||
643 | |||
608 | local function lem_rdg_totei(str) | 644 | local function lem_rdg_totei(str) |
609 | str = gsub(str, dblbkslash * lemrdg * spcenc^-1 * bsqbrackets * bcbraces, | 645 | str = gsub(str, dblbkslash * lemrdg * spcenc^-1 * bsqbrackets * bcbraces, |
610 | function(bkslash, cmd, opt, arg) | 646 | function(bkslash, cmd, opt, arg) |
@@ -623,10 +659,10 @@ end | |||
623 | function ekdosis.textotei(str) | 659 | function ekdosis.textotei(str) |
624 | str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>") | 660 | str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>") |
625 | str = lem_rdg_totei(str) | 661 | str = lem_rdg_totei(str) |
626 | for i = 1,#tags | 662 | for i = 1,#cmdtotags |
627 | do | 663 | do |
628 | str = string.gsub(str, "(\\"..tags[i].a..")%s?(%b{})", "%1[]%2") | 664 | str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?(%b{})", "%1[]%2") |
629 | str = string.gsub(str, "(\\"..tags[i].a..")%s?(%b[])(%b{})", | 665 | str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?(%b[])(%b{})", |
630 | function(cmd, arg, body) | 666 | function(cmd, arg, body) |
631 | body = string.sub(body, 2, -2) | 667 | body = string.sub(body, 2, -2) |
632 | arg = string.sub(arg, 2, -2) | 668 | arg = string.sub(arg, 2, -2) |
@@ -635,7 +671,7 @@ function ekdosis.textotei(str) | |||
635 | return string.format("\"%s\"", braces) | 671 | return string.format("\"%s\"", braces) |
636 | end) | 672 | end) |
637 | body = ekdosis.textotei(body) | 673 | body = ekdosis.textotei(body) |
638 | return string.format("<"..tags[i].b..tags[i].c.." %s>%s</"..tags[i].b..">", arg, body) | 674 | return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body) |
639 | end) | 675 | end) |
640 | end | 676 | end |
641 | str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})", | 677 | str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})", |
@@ -708,7 +744,7 @@ ekdosis.getabspg = function(pg) --not used | |||
708 | end | 744 | end |
709 | end | 745 | end |
710 | 746 | ||
711 | local function isintable(table, value) | 747 | local function mdvisintable(table, value) |
712 | for _, v in pairs(table) do | 748 | for _, v in pairs(table) do |
713 | if v == value then return true end | 749 | if v == value then return true end |
714 | end | 750 | end |
@@ -761,7 +797,7 @@ local salt = 0 | |||
761 | 797 | ||
762 | function ekdosis.mdvappend(str) | 798 | function ekdosis.mdvappend(str) |
763 | i = md5.sumhexa(str) | 799 | i = md5.sumhexa(str) |
764 | if not isintable(md5items, i) then | 800 | if not mdvisintable(md5items, i) then |
765 | table.insert(md5items, i) | 801 | table.insert(md5items, i) |
766 | else | 802 | else |
767 | i = i..salt | 803 | i = i..salt |