diff options
author | Robert Alessi <alessi@robertalessi.net> | 2020-04-22 14:57:37 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2020-04-22 14:59:29 +0200 |
commit | 8976e160e584d67178ab14ee2110429a99623223 (patch) | |
tree | 10bd5cb775ba78c321ee92ba2af76008e9bd69ad | |
parent | 7d3ff2b76d62d69d36a90bba0d306d920ae5b415 (diff) | |
download | ekdosis-8976e160e584d67178ab14ee2110429a99623223.tar.gz |
shorter version of envtotei()
-rw-r--r-- | ekdosis.dtx | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index 257af7c..72d9904 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -1630,51 +1630,42 @@ end | |||
1630 | local function envtotei(str) | 1630 | local function envtotei(str) |
1631 | for i = 1,#envtotags | 1631 | for i = 1,#envtotags |
1632 | do | 1632 | do |
1633 | if envtotags[i].b ~= "" and isfound(close_p, envtotags[i].b) | 1633 | if envtotags[i].b ~= "" |
1634 | then | 1634 | then |
1635 | if envtotags[i].b == "p" | 1635 | if isfound(close_p, envtotags[i].b) |
1636 | then | 1636 | then |
1637 | str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | 1637 | if envtotags[i].b == "p" |
1638 | then | ||
1639 | str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | ||
1640 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | ||
1641 | * bsqbracketsii * bcbracesii * spcenc^-1, | ||
1642 | "\n<"..envtotags[i].b..envtotags[i].c..">") | ||
1643 | else | ||
1644 | str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | ||
1645 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | ||
1646 | * bsqbracketsii * bcbracesii * spcenc^-1, | ||
1647 | "</p>\n<"..envtotags[i].b..envtotags[i].c..">") | ||
1648 | end | ||
1649 | str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") | ||
1650 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * (lpeg.P("\\par") + lpeg.P("</p>")), | ||
1651 | "</"..envtotags[i].b..">\n<p>") | ||
1652 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | ||
1638 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | 1653 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") |
1639 | * bsqbracketsii * bcbracesii * spcenc^-1, | 1654 | * bsqbracketsii * bcbracesii * spcenc^-1, |
1640 | "\n<"..envtotags[i].b..envtotags[i].c..">") | 1655 | "<"..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..">\n<p>") | ||
1641 | else | 1659 | else |
1642 | str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | 1660 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") |
1643 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | 1661 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") |
1644 | * bsqbracketsii * bcbracesii * spcenc^-1, | 1662 | * bsqbracketsii * bcbracesii * spcenc^-1, |
1645 | "</p>\n<"..envtotags[i].b..envtotags[i].c..">") | 1663 | "<"..envtotags[i].b..envtotags[i].c..">") |
1664 | str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") | ||
1665 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), | ||
1666 | "</"..envtotags[i].b..">") | ||
1646 | end | 1667 | 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 | 1668 | 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..">") | ||
1671 | else | ||
1672 | end | ||
1673 | end | ||
1674 | for i = 1,#envtotags | ||
1675 | do | ||
1676 | if envtotags[i].b == "" | ||
1677 | then | ||
1678 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | 1669 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") |
1679 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | 1670 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") |
1680 | * bsqbracketsii * bcbracesii * spcenc^-1, | 1671 | * bsqbracketsii * bcbracesii * spcenc^-1, |
@@ -1682,7 +1673,6 @@ local function envtotei(str) | |||
1682 | str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") | 1673 | str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") |
1683 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), | 1674 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), |
1684 | "") | 1675 | "") |
1685 | else | ||
1686 | end | 1676 | end |
1687 | end | 1677 | end |
1688 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | 1678 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") |