aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r--ekdosis.dtx140
1 files changed, 2 insertions, 138 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 16c332e..22f9c9d 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -561,8 +561,8 @@ Running "make install" installs the files in the local TeX tree.
561\def\ekd@default@rule{\rule{2truein}{0.5pt}} 561\def\ekd@default@rule{\rule{2truein}{0.5pt}}
562 % \def\ekd@default@rule{\vskip-\baselineskip\mbox{}\newline% 562 % \def\ekd@default@rule{\vskip-\baselineskip\mbox{}\newline%
563 % \rule{2truein}{0.5pt}} 563 % \rule{2truein}{0.5pt}}
564% \def\footnoterule{\vskip-\baselineskip} 564 % \def\footnoterule{\vskip-\baselineskip}
565% \def\pcol@footnoterule{} 565 % \def\pcol@footnoterule{}
566\newif\iffootnoterule 566\newif\iffootnoterule
567\let\dflt@footnoterule\footnoterule 567\let\dflt@footnoterule\footnoterule
568\let\dflt@pcol@footnoterule\pcol@footnoterule 568\let\dflt@pcol@footnoterule\pcol@footnoterule
@@ -1511,11 +1511,6 @@ local close_p = {
1511function ekdosis.newcmdtotag(cmd, tag, attr) 1511function ekdosis.newcmdtotag(cmd, tag, attr)
1512 if isintable(cmdtotags, cmd) 1512 if isintable(cmdtotags, cmd)
1513 then 1513 then
1514 -- tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
1515 -- ..cmd..
1516 -- "\" already exists as a known command to be processed to TEI. "
1517 -- ..
1518 -- "Please pick another command.}}")
1519 local index = get_a_index(cmd, cmdtotags) 1514 local index = get_a_index(cmd, cmdtotags)
1520 table.remove(cmdtotags, index) 1515 table.remove(cmdtotags, index)
1521 table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr}) 1516 table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr})
@@ -1538,24 +1533,13 @@ end
1538function ekdosis.newenvtotag(env, tag, attr, closep) 1533function ekdosis.newenvtotag(env, tag, attr, closep)
1539 if isintable(envtotags, env) 1534 if isintable(envtotags, env)
1540 then 1535 then
1541 -- tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
1542 -- ..cmd..
1543 -- "\" already exists as a known environment to be processed to TEI. "
1544 -- ..
1545 -- "Please pick another environment name.}}")
1546 local index = get_a_index(env, envtotags) 1536 local index = get_a_index(env, envtotags)
1547 table.remove(envtotags, index) 1537 table.remove(envtotags, index)
1548 table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep}) 1538 table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep})
1549 table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end) 1539 table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end)
1550 -- if closep == "yes" then
1551 -- table.insert(close_p, tag)
1552 -- else end
1553 else 1540 else
1554 table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep}) 1541 table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep})
1555 table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end) 1542 table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end)
1556 -- if closep == "yes" then
1557 -- table.insert(close_p, tag)
1558 -- else end
1559 end 1543 end
1560 return true 1544 return true
1561end 1545end
@@ -1593,32 +1577,8 @@ local function note_totei(str)
1593 arg = string.sub(arg, 2, -2) 1577 arg = string.sub(arg, 2, -2)
1594 teitype = get_attr_value(opt, "type") 1578 teitype = get_attr_value(opt, "type")
1595 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end 1579 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
1596 -- teitype = string.match(opt, "%f[%w]type%s?%=%s?%b{}")
1597 -- or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]")
1598 -- or ""
1599 -- teitype = string.gsub(teitype, "type%s?%=%s?(%b{})", function(bbraces)
1600 -- bbraces = string.sub(bbraces, 2, -2)
1601 -- return string.format("%s", bbraces)
1602 -- end)
1603 -- teitype = string.gsub(teitype, "(type%s?%=%s?)(%w+%f[%W])", "%2")
1604 right = get_attr_value(opt, "labelb") 1580 right = get_attr_value(opt, "labelb")
1605 -- right = string.match(opt, "%f[%w]labelb%s?%=%s?%b{}")
1606 -- or string.match(opt, "%f[%w]labelb%s?%=%s?%w+%f[%W]")
1607 -- or ""
1608 -- right = string.gsub(right, "labelb%s?%=%s?(%b{})", function(bbraces)
1609 -- bbraces = string.sub(bbraces, 2, -2)
1610 -- return string.format("%s", bbraces)
1611 -- end)
1612 -- right = string.gsub(right, "(labelb%s?%=%s?)(%w+%f[%W])", "%2")
1613 left = get_attr_value(opt, "labele") 1581 left = get_attr_value(opt, "labele")
1614 -- left = string.match(opt, "%f[%w]labele%s?%=%s?%b{}")
1615 -- or string.match(opt, "%f[%w]labele%s?%=%s?%w+%f[%W]")
1616 -- or ""
1617 -- left = string.gsub(left, "labele%s?%=%s?(%b{})", function(bbraces)
1618 -- bbraces = string.sub(bbraces, 2, -2)
1619 -- return string.format("%s", bbraces)
1620 -- end)
1621 -- left = string.gsub(left, "(labele%s?%=%s?)(%w+%f[%W])", "%2")
1622 if left ~= "" 1582 if left ~= ""
1623 then 1583 then
1624 return string.format( 1584 return string.format(
@@ -1630,26 +1590,6 @@ local function note_totei(str)
1630 "<%s%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>", 1590 "<%s%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
1631 cmd, teitype, right, arg, cmd, right) 1591 cmd, teitype, right, arg, cmd, right)
1632 end 1592 end
1633 --
1634 -- if left ~= "" and teitype ~= ""
1635 -- then
1636 -- return string.format(
1637 -- "<%s type=\"%s\" target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>",
1638 -- cmd, teitype, right, left, arg, cmd, right)
1639 -- elseif left ~= "" and teitype == ""
1640 -- then
1641 -- return string.format(
1642 -- "<%s target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>",
1643 -- cmd, right, left, arg, cmd, right)
1644 -- elseif left == "" and teitype ~= ""
1645 -- then
1646 -- return string.format(
1647 -- "<%s type=\"%s\" target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
1648 -- cmd, teitype, right, arg, cmd, right)
1649 -- else
1650 -- return string.format("<%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
1651 -- cmd, right, arg, cmd, right)
1652 -- end
1653 end) 1593 end)
1654 return str 1594 return str
1655end 1595end
@@ -1667,24 +1607,8 @@ local function app_totei(str)
1667 arg = string.sub(arg, 2, -2) 1607 arg = string.sub(arg, 2, -2)
1668 opt = get_attr_value(opt, "type") 1608 opt = get_attr_value(opt, "type")
1669 if opt ~= "" then opt = " type=\""..opt.."\"" else end 1609 if opt ~= "" then opt = " type=\""..opt.."\"" else end
1670 -- opt = string.match(opt, "%f[%w]type%s?%=%s?%b{}")
1671 -- or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]")
1672 -- or ""
1673 -- opt = string.gsub(opt, "type%s?%=%s?(%b{})", function(bbraces)
1674 -- bbraces = string.sub(bbraces, 2, -2)
1675 -- return string.format("%s", bbraces)
1676 -- end)
1677 -- opt = string.gsub(opt, "(type%s?%=%s?)(%w+%f[%W])", "%2")
1678 return app_totei(string.format("<%s%s>%s</%s>", 1610 return app_totei(string.format("<%s%s>%s</%s>",
1679 cmd, opt, arg, cmd)) 1611 cmd, opt, arg, cmd))
1680 -- if opt == ""
1681 -- then
1682 -- return app_totei(string.format("<%s>%s</%s>",
1683 -- cmd, arg, cmd))
1684 -- else
1685 -- return app_totei(string.format("<%s type=\"%s\">%s</%s>",
1686 -- cmd, opt, arg, cmd))
1687 -- end
1688 end) 1612 end)
1689 return str 1613 return str
1690end 1614end
@@ -1701,24 +1625,12 @@ local function lem_rdg_totei(str)
1701 function(bkslash, cmd, opt, arg) 1625 function(bkslash, cmd, opt, arg)
1702 opt = string.sub(opt, 2, -2) 1626 opt = string.sub(opt, 2, -2)
1703 arg = string.sub(arg, 2, -2) 1627 arg = string.sub(arg, 2, -2)
1704 -- opt = string.match(opt, "%f[%w]wit%s?%=%s?%b{}")
1705 -- or string.match(opt, "%f[%w]wit%s?%=%s?%w+%f[%W]")
1706 -- or ""
1707 opt = get_attr_value(opt, "wit") 1628 opt = get_attr_value(opt, "wit")
1708 if opt == "" 1629 if opt == ""
1709 then 1630 then
1710 return lem_rdg_totei(string.format("<%s>%s</%s>", 1631 return lem_rdg_totei(string.format("<%s>%s</%s>",
1711 cmd, arg, cmd)) 1632 cmd, arg, cmd))
1712 else 1633 else
1713 -- opt = string.gsub(opt, "wit%s?%=%s?(%b{})", function(bbraces)
1714 -- bbraces = string.sub(bbraces, 2, -2)
1715 -- bbraces = ekdosis.getsiglum(bbraces, "tei")
1716 -- return string.format("%s", bbraces)
1717 -- end)
1718 -- opt = string.gsub(opt, "(wit%s?%=%s?)(%w+%f[%W])", function(attr, value)
1719 -- value = ekdosis.getsiglum(value, "tei")
1720 -- return string.format("%s", value)
1721 -- end)
1722 opt = ekdosis.getsiglum(opt, "tei") 1634 opt = ekdosis.getsiglum(opt, "tei")
1723 return lem_rdg_totei(string.format("<%s wit=\"%s\">%s</%s>", 1635 return lem_rdg_totei(string.format("<%s wit=\"%s\">%s</%s>",
1724 cmd, opt, arg, cmd)) 1636 cmd, opt, arg, cmd))
@@ -1729,7 +1641,6 @@ local function lem_rdg_totei(str)
1729 arg = string.sub(arg, 2, -2) 1641 arg = string.sub(arg, 2, -2)
1730 return lem_rdg_totei(string.format("<%s>%s</%s>", cmd, arg, cmd)) 1642 return lem_rdg_totei(string.format("<%s>%s</%s>", cmd, arg, cmd))
1731 end) 1643 end)
1732 -- str = string.gsub(str, "(%<lem.-%>.-)(%<note.-%<%/note%>)(.-%<%/lem%>)", "%1%3%2")
1733 return str 1644 return str
1734end 1645end
1735 1646
@@ -1776,21 +1687,6 @@ local function envtotei(str)
1776 then 1687 then
1777 if isfound(close_p, envtotags[i].b) or envtotags[i].d == "yes" 1688 if isfound(close_p, envtotags[i].b) or envtotags[i].d == "yes"
1778 then 1689 then
1779 -- if envtotags[i].b == "p"
1780 -- then
1781 -- str = gsub(str, lpeg.P("\\par") * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1782 -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1783 -- * bcbracesii * spcenc^-1,
1784 -- "\n<"..envtotags[i].b..envtotags[i].c..">")
1785 -- else
1786 -- str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1787 -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1788 -- * bcbracesii * spcenc^-1,
1789 -- "</p>\n<"..envtotags[i].b..envtotags[i].c..">")
1790 -- end
1791 -- str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1792 -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * lpeg.P("\\par"),
1793 -- "</"..envtotags[i].b..">\n")
1794 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1690 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1795 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1691 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1796 * bcbracesii * spcenc^-1, 1692 * bcbracesii * spcenc^-1,
@@ -1889,39 +1785,13 @@ local function partotei(str)
1889 str = string.gsub(str, "\\p@ra%s+", "<p>") 1785 str = string.gsub(str, "\\p@ra%s+", "<p>")
1890 str = string.gsub(str, "\\p@rb%s+", "</p>") 1786 str = string.gsub(str, "\\p@rb%s+", "</p>")
1891 str = string.gsub(str, "\\p@r%s+", "") 1787 str = string.gsub(str, "\\p@r%s+", "")
1892-- str = gsub(str, lpeg.P(lpeg.P("\\p@r") * spcenc^1)^1, "\\p@r ")
1893-- str = gsub(str, lpeg.P(lpeg.P("\\p@r") * spcenc^1 * (lpeg.P("\\par") * spcenc^1)^-1)^1, "\\p@r ")
1894 str = string.gsub(str, "%s?\\par%s?", "<p>", 1) 1788 str = string.gsub(str, "%s?\\par%s?", "<p>", 1)
1895 --str = string.gsub(str, "(\\par)(%s-)(%<%/?div%d?)", "%3")
1896 str = string.gsub(str, "(%<p%>)(%s-)(%<%/?div%d?)", "%3") 1789 str = string.gsub(str, "(%<p%>)(%s-)(%<%/?div%d?)", "%3")
1897 str = string.gsub(str, "%s?\\par%s?", "</p><p>") 1790 str = string.gsub(str, "%s?\\par%s?", "</p><p>")
1898 str = string.gsub(str, "<p>%s?</p>", "") 1791 str = string.gsub(str, "<p>%s?</p>", "")
1899 str = string.gsub(str, "(%<p%>)%s?(%</div%>)$", "%2") 1792 str = string.gsub(str, "(%<p%>)%s?(%</div%>)$", "%2")
1900 str = string.gsub(str, "(%<p%>)%s?$", "") 1793 str = string.gsub(str, "(%<p%>)%s?$", "")
1901 str = string.gsub(str, "(<p>)%s?(<div.->)", "%2%1") 1794 str = string.gsub(str, "(<p>)%s?(<div.->)", "%2%1")
1902 -- str = string.gsub(str, "(%<p%>)%s?(<head>.-</head>)", "%2%1")
1903 return str
1904end
1905
1906local function checkpars(str)
1907 for i = 1,#envtotags
1908 do
1909 if isfound(close_p, envtotags[i].b)
1910 then
1911 str = string.gsub(str, "(%<p[%>%s])(.-<"..envtotags[i].b.."[%>%s])", function(par, substr_tag)
1912 substr_tag = checkpars(substr_tag)
1913 substr = string.gsub(substr_tag, "(.-)(<"..envtotags[i].b.."[%>%s])", "%1")
1914 tag = string.gsub(substr_tag, "(.-)(<"..envtotags[i].b.."[%>%s])", "%2")
1915 if string.find(substr, "<%/p[%>%s]")
1916 then
1917 return string.format("%s%s%s", par, substr, tag)
1918 else
1919 return string.format("%s%s</p>%s", par, substr, tag)
1920 end
1921 end)
1922 else
1923 end
1924 end
1925 return str 1795 return str
1926end 1796end
1927 1797
@@ -2009,13 +1879,10 @@ local function ekddivs_totei(str)
2009 if ekddivs 1879 if ekddivs
2010 then 1880 then
2011 arg = string.sub(arg, 2, -2) 1881 arg = string.sub(arg, 2, -2)
2012-- arg = arg..","
2013 --
2014 teitype = get_attr_value(arg, "type") 1882 teitype = get_attr_value(arg, "type")
2015 tein = get_attr_value(arg, "n") 1883 tein = get_attr_value(arg, "n")
2016 teihead = get_attr_value(arg, "head") 1884 teihead = get_attr_value(arg, "head")
2017 teidepth = get_attr_value(arg, "depth") 1885 teidepth = get_attr_value(arg, "depth")
2018 --
2019 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end 1886 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
2020 if tein ~= "" then tein = " n=\""..tein.."\"" else end 1887 if tein ~= "" then tein = " n=\""..tein.."\"" else end
2021 if teidepth ~= "" 1888 if teidepth ~= ""
@@ -2095,7 +1962,6 @@ local function close_ekddivs_at_end(str)
2095 lastdivindex = lastdivindex - 1 1962 lastdivindex = lastdivindex - 1
2096 end 1963 end
2097 end 1964 end
2098-- str = string.gsub(str, "(<div)([1-6])(.->)", "%1%3")
2099 if isdiv 1965 if isdiv
2100 then 1966 then
2101 return str..closedivs.."</div>" 1967 return str..closedivs.."</div>"
@@ -2144,7 +2010,6 @@ local function close_ndivs_at_end(str)
2144 lastdivindex = lastdivindex - 1 2010 lastdivindex = lastdivindex - 1
2145 end 2011 end
2146 end 2012 end
2147-- str = string.gsub(str, "(<div)([1-6])(.->)", "%1%3")
2148 if isdiv 2013 if isdiv
2149 then 2014 then
2150 return str..closedivs.."</div>" 2015 return str..closedivs.."</div>"
@@ -2234,7 +2099,6 @@ local function textotei(str)
2234 str = cmdtotei(str) 2099 str = cmdtotei(str)
2235 str = self_close_tags(str) 2100 str = self_close_tags(str)
2236 str = partotei(str) 2101 str = partotei(str)
2237-- str = checkpars(str)
2238 if ekddivs 2102 if ekddivs
2239 then 2103 then
2240 str = close_ekddivs_at_end(str) 2104 str = close_ekddivs_at_end(str)