aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r--ekdosis.dtx158
1 files changed, 93 insertions, 65 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index a30f801..9978cd0 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1562,6 +1562,7 @@ end
1562 1562
1563-- Get values of attributes 1563-- Get values of attributes
1564local function get_attr_value(str, attr) 1564local function get_attr_value(str, attr)
1565 str = str..","
1565 local attrval = string.match(str, "%f[%w]"..attr.."%s?%=%s?%b{}") 1566 local attrval = string.match(str, "%f[%w]"..attr.."%s?%=%s?%b{}")
1566 or string.match(str, "%f[%w]"..attr.."%s?%=%s?.-%,") 1567 or string.match(str, "%f[%w]"..attr.."%s?%=%s?.-%,")
1567 or "" 1568 or ""
@@ -1590,50 +1591,65 @@ local function note_totei(str)
1590 function(bkslash, cmd, opt, arg) 1591 function(bkslash, cmd, opt, arg)
1591 opt = string.sub(opt, 2, -2) 1592 opt = string.sub(opt, 2, -2)
1592 arg = string.sub(arg, 2, -2) 1593 arg = string.sub(arg, 2, -2)
1593 teitype = string.match(opt, "%f[%w]type%s?%=%s?%b{}") 1594 teitype = get_attr_value(opt, "type")
1594 or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]") 1595 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
1595 or "" 1596 -- teitype = string.match(opt, "%f[%w]type%s?%=%s?%b{}")
1596 teitype = string.gsub(teitype, "type%s?%=%s?(%b{})", function(bbraces) 1597 -- or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]")
1597 bbraces = string.sub(bbraces, 2, -2) 1598 -- or ""
1598 return string.format("%s", bbraces) 1599 -- teitype = string.gsub(teitype, "type%s?%=%s?(%b{})", function(bbraces)
1599 end) 1600 -- bbraces = string.sub(bbraces, 2, -2)
1600 teitype = string.gsub(teitype, "(type%s?%=%s?)(%w+%f[%W])", "%2") 1601 -- return string.format("%s", bbraces)
1601 right = string.match(opt, "%f[%w]labelb%s?%=%s?%b{}") 1602 -- end)
1602 or string.match(opt, "%f[%w]labelb%s?%=%s?%w+%f[%W]") 1603 -- teitype = string.gsub(teitype, "(type%s?%=%s?)(%w+%f[%W])", "%2")
1603 or "" 1604 right = get_attr_value(opt, "labelb")
1604 right = string.gsub(right, "labelb%s?%=%s?(%b{})", function(bbraces) 1605 -- right = string.match(opt, "%f[%w]labelb%s?%=%s?%b{}")
1605 bbraces = string.sub(bbraces, 2, -2) 1606 -- or string.match(opt, "%f[%w]labelb%s?%=%s?%w+%f[%W]")
1606 return string.format("%s", bbraces) 1607 -- or ""
1607 end) 1608 -- right = string.gsub(right, "labelb%s?%=%s?(%b{})", function(bbraces)
1608 right = string.gsub(right, "(labelb%s?%=%s?)(%w+%f[%W])", "%2") 1609 -- bbraces = string.sub(bbraces, 2, -2)
1609 left = string.match(opt, "%f[%w]labele%s?%=%s?%b{}") 1610 -- return string.format("%s", bbraces)
1610 or string.match(opt, "%f[%w]labele%s?%=%s?%w+%f[%W]") 1611 -- end)
1611 or "" 1612 -- right = string.gsub(right, "(labelb%s?%=%s?)(%w+%f[%W])", "%2")
1612 left = string.gsub(left, "labele%s?%=%s?(%b{})", function(bbraces) 1613 left = get_attr_value(opt, "labele")
1613 bbraces = string.sub(bbraces, 2, -2) 1614 -- left = string.match(opt, "%f[%w]labele%s?%=%s?%b{}")
1614 return string.format("%s", bbraces) 1615 -- or string.match(opt, "%f[%w]labele%s?%=%s?%w+%f[%W]")
1615 end) 1616 -- or ""
1616 left = string.gsub(left, "(labele%s?%=%s?)(%w+%f[%W])", "%2") 1617 -- left = string.gsub(left, "labele%s?%=%s?(%b{})", function(bbraces)
1617 1618 -- bbraces = string.sub(bbraces, 2, -2)
1618 if left ~= "" and teitype ~= "" 1619 -- return string.format("%s", bbraces)
1619 then 1620 -- end)
1620 return string.format( 1621 -- left = string.gsub(left, "(labele%s?%=%s?)(%w+%f[%W])", "%2")
1621 "<%s type=\"%s\" target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>", 1622 if left ~= ""
1622 cmd, teitype, right, left, arg, cmd, right)
1623 elseif left ~= "" and teitype == ""
1624 then 1623 then
1625 return string.format( 1624 return string.format(
1626 "<%s target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>", 1625 "<%s%s target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>",
1627 cmd, right, left, arg, cmd, right) 1626 cmd, teitype, right, left, arg, cmd, right)
1628 elseif left == "" and teitype ~= "" 1627 elseif left == ""
1629 then 1628 then
1630 return string.format( 1629 return string.format(
1631 "<%s type=\"%s\" target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>", 1630 "<%s%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
1632 cmd, teitype, right, arg, cmd, right) 1631 cmd, teitype, right, arg, cmd, right)
1633 else
1634 return string.format("<%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
1635 cmd, right, arg, cmd, right)
1636 end 1632 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
1637 end) 1653 end)
1638 return str 1654 return str
1639end 1655end
@@ -1649,16 +1665,26 @@ local function app_totei(str)
1649 function(bkslash, cmd, opt, arg) 1665 function(bkslash, cmd, opt, arg)
1650 opt = string.sub(opt, 2, -2) 1666 opt = string.sub(opt, 2, -2)
1651 arg = string.sub(arg, 2, -2) 1667 arg = string.sub(arg, 2, -2)
1652 opt = string.match(opt, "%f[%w]type%s?%=%s?%b{}") 1668 opt = get_attr_value(opt, "type")
1653 or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]") 1669 if opt ~= "" then opt = " type=\""..opt.."\"" else end
1654 or "" 1670 -- opt = string.match(opt, "%f[%w]type%s?%=%s?%b{}")
1655 opt = string.gsub(opt, "type%s?%=%s?(%b{})", function(bbraces) 1671 -- or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]")
1656 bbraces = string.sub(bbraces, 2, -2) 1672 -- or ""
1657 return string.format("%s", bbraces) 1673 -- opt = string.gsub(opt, "type%s?%=%s?(%b{})", function(bbraces)
1658 end) 1674 -- bbraces = string.sub(bbraces, 2, -2)
1659 opt = string.gsub(opt, "(type%s?%=%s?)(%w+%f[%W])", "%2") 1675 -- return string.format("%s", bbraces)
1660 return app_totei(string.format("<%s type=\"%s\">%s</%s>", 1676 -- end)
1661 cmd, opt, arg, cmd)) 1677 -- opt = string.gsub(opt, "(type%s?%=%s?)(%w+%f[%W])", "%2")
1678 return app_totei(string.format("<%s%s>%s</%s>",
1679 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
1662 end) 1688 end)
1663 return str 1689 return str
1664end 1690end
@@ -1675,23 +1701,25 @@ local function lem_rdg_totei(str)
1675 function(bkslash, cmd, opt, arg) 1701 function(bkslash, cmd, opt, arg)
1676 opt = string.sub(opt, 2, -2) 1702 opt = string.sub(opt, 2, -2)
1677 arg = string.sub(arg, 2, -2) 1703 arg = string.sub(arg, 2, -2)
1678 opt = string.match(opt, "%f[%w]wit%s?%=%s?%b{}") 1704 -- opt = string.match(opt, "%f[%w]wit%s?%=%s?%b{}")
1679 or string.match(opt, "%f[%w]wit%s?%=%s?%w+%f[%W]") 1705 -- or string.match(opt, "%f[%w]wit%s?%=%s?%w+%f[%W]")
1680 or "" 1706 -- or ""
1707 opt = get_attr_value(opt, "wit")
1681 if opt == "" 1708 if opt == ""
1682 then 1709 then
1683 return lem_rdg_totei(string.format("<%s>%s</%s>", 1710 return lem_rdg_totei(string.format("<%s>%s</%s>",
1684 cmd, arg, cmd)) 1711 cmd, arg, cmd))
1685 else 1712 else
1686 opt = string.gsub(opt, "wit%s?%=%s?(%b{})", function(bbraces) 1713 -- opt = string.gsub(opt, "wit%s?%=%s?(%b{})", function(bbraces)
1687 bbraces = string.sub(bbraces, 2, -2) 1714 -- bbraces = string.sub(bbraces, 2, -2)
1688 bbraces = ekdosis.getsiglum(bbraces, "tei") 1715 -- bbraces = ekdosis.getsiglum(bbraces, "tei")
1689 return string.format("%s", bbraces) 1716 -- return string.format("%s", bbraces)
1690 end) 1717 -- end)
1691 opt = string.gsub(opt, "(wit%s?%=%s?)(%w+%f[%W])", function(attr, value) 1718 -- opt = string.gsub(opt, "(wit%s?%=%s?)(%w+%f[%W])", function(attr, value)
1692 value = ekdosis.getsiglum(value, "tei") 1719 -- value = ekdosis.getsiglum(value, "tei")
1693 return string.format("%s", value) 1720 -- return string.format("%s", value)
1694 end) 1721 -- end)
1722 opt = ekdosis.getsiglum(opt, "tei")
1695 return lem_rdg_totei(string.format("<%s wit=\"%s\">%s</%s>", 1723 return lem_rdg_totei(string.format("<%s wit=\"%s\">%s</%s>",
1696 cmd, opt, arg, cmd)) 1724 cmd, opt, arg, cmd))
1697 end 1725 end
@@ -1858,9 +1886,9 @@ end
1858local function partotei(str) 1886local function partotei(str)
1859 str = gsub(str, lpeg.P(lpeg.P("\\par") * spcenc^1)^1, "\\par ") 1887 str = gsub(str, lpeg.P(lpeg.P("\\par") * spcenc^1)^1, "\\par ")
1860 str = gsub(str, ((para + parb) * par^-1)^2, "\\p@r ") 1888 str = gsub(str, ((para + parb) * par^-1)^2, "\\p@r ")
1861 str = string.gsub(str, "\\p@ra%s?", "<p>") 1889 str = string.gsub(str, "\\p@ra%s+", "<p>")
1862 str = string.gsub(str, "\\p@rb%s?", "</p>") 1890 str = string.gsub(str, "\\p@rb%s+", "</p>")
1863 str = string.gsub(str, "\\p@r%s?", "") 1891 str = string.gsub(str, "\\p@r%s+", "")
1864-- str = gsub(str, lpeg.P(lpeg.P("\\p@r") * spcenc^1)^1, "\\p@r ") 1892-- str = gsub(str, lpeg.P(lpeg.P("\\p@r") * spcenc^1)^1, "\\p@r ")
1865-- str = gsub(str, lpeg.P(lpeg.P("\\p@r") * spcenc^1 * (lpeg.P("\\par") * spcenc^1)^-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 ")
1866 str = string.gsub(str, "%s?\\par%s?", "<p>", 1) 1894 str = string.gsub(str, "%s?\\par%s?", "<p>", 1)
@@ -1981,7 +2009,7 @@ local function ekddivs_totei(str)
1981 if ekddivs 2009 if ekddivs
1982 then 2010 then
1983 arg = string.sub(arg, 2, -2) 2011 arg = string.sub(arg, 2, -2)
1984 arg = arg.."," 2012-- arg = arg..","
1985 -- 2013 --
1986 teitype = get_attr_value(arg, "type") 2014 teitype = get_attr_value(arg, "type")
1987 tein = get_attr_value(arg, "n") 2015 tein = get_attr_value(arg, "n")