aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2020-04-22 13:08:46 +0200
committerRobert Alessi <alessi@robertalessi.net>2020-04-22 13:08:46 +0200
commit7d3ff2b76d62d69d36a90bba0d306d920ae5b415 (patch)
treee6a209726e620eab3f79ea9668fa48eee1ac73be
parent16b22006e1c52469314047d7824e76b0b4c2e90f (diff)
downloadekdosis-7d3ff2b76d62d69d36a90bba0d306d920ae5b415.tar.gz
insert in <div> tags attributes collected by mkenvdata()
-rw-r--r--ekdosis.dtx78
1 files changed, 57 insertions, 21 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 64122d3..257af7c 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1630,34 +1630,51 @@ end
1630local function envtotei(str) 1630local function envtotei(str)
1631 for i = 1,#envtotags 1631 for i = 1,#envtotags
1632 do 1632 do
1633 if envtotags[i].b ~= "" 1633 if envtotags[i].b ~= "" and isfound(close_p, envtotags[i].b)
1634 then 1634 then
1635 if isfound(close_p, envtotags[i].b) 1635 if envtotags[i].b == "p"
1636 then 1636 then
1637 str = gsub(str, lpeg.P("\\par") * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1637 str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1638 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1638 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1639 * bsqbracketsii * bcbracesii * spcenc^-1, 1639 * bsqbracketsii * bcbracesii * spcenc^-1,
1640 "</p>\n<"..envtotags[i].b..envtotags[i].c..">") 1640 "\n<"..envtotags[i].b..envtotags[i].c..">")
1641 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1642 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * lpeg.P("\\par"),
1643 "</"..envtotags[i].b..">\n<p>")
1644 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1645 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1646 * bsqbracketsii * bcbracesii * spcenc^-1,
1647 "<"..envtotags[i].b..envtotags[i].c..">")
1648 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1649 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1650 "</"..envtotags[i].b..">\n<p>")
1651 else 1641 else
1652 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1642 str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1653 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1643 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1654 * bsqbracketsii * bcbracesii * spcenc^-1, 1644 * bsqbracketsii * bcbracesii * spcenc^-1,
1655 "<"..envtotags[i].b..envtotags[i].c..">") 1645 "</p>\n<"..envtotags[i].b..envtotags[i].c..">")
1656 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1657 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1658 "</"..envtotags[i].b..">")
1659 end 1646 end
1647 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1648 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * (lpeg.P("\\par") + lpeg.P("</p>")),
1649 "</"..envtotags[i].b..">\n<p>")
1650 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1651 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1652 * bsqbracketsii * bcbracesii * spcenc^-1,
1653 "<"..envtotags[i].b..envtotags[i].c..">")
1654 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1655 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1656 "</"..envtotags[i].b..">\n<p>")
1657 else
1658 end
1659 end
1660 for i = 1,#envtotags
1661 do
1662 if envtotags[i].b ~= "" and not isfound(close_p, envtotags[i].b)
1663 then
1664 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1665 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1666 * bsqbracketsii * bcbracesii * spcenc^-1,
1667 "<"..envtotags[i].b..envtotags[i].c..">")
1668 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1669 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1670 "</"..envtotags[i].b..">")
1660 else 1671 else
1672 end
1673 end
1674 for i = 1,#envtotags
1675 do
1676 if envtotags[i].b == ""
1677 then
1661 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1678 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1662 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1679 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1663 * bsqbracketsii * bcbracesii * spcenc^-1, 1680 * bsqbracketsii * bcbracesii * spcenc^-1,
@@ -1665,6 +1682,7 @@ local function envtotei(str)
1665 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") 1682 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1666 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), 1683 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1667 "") 1684 "")
1685 else
1668 end 1686 end
1669 end 1687 end
1670 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1688 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
@@ -2144,6 +2162,24 @@ function ekdosis.mkenv()
2144 ..", \\luastringN{\\par#1\\par})}\\fi" 2162 ..", \\luastringN{\\par#1\\par})}\\fi"
2145 .."}") 2163 .."}")
2146 end 2164 end
2165 if aligned_texts[i].attribute ~= ""
2166 then
2167 table.insert(environments, "\\EnvtoTEI{"
2168 .. aligned_texts[i].text
2169 .."}{div}"
2170 .."[xml:id=\"div-"
2171 .. aligned_texts[i].text
2172 .. "\" "
2173 .. aligned_texts[i].attribute
2174 .. "]")
2175 else
2176 table.insert(environments, "\\EnvtoTEI{"
2177 .. aligned_texts[i].text
2178 .."}{div}"
2179 .."[xml:id=\"div-"
2180 .. aligned_texts[i].text
2181 .. "\"]")
2182 end
2147 end 2183 end
2148 str = table.concat(environments) 2184 str = table.concat(environments)
2149 return str 2185 return str