aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r--ekdosis.dtx37
1 files changed, 24 insertions, 13 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index cbd6637..41025b5 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1267,6 +1267,9 @@ local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1)
1267local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter") 1267local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter")
1268 + lpeg.P("section") + lpeg.P("subsection") 1268 + lpeg.P("section") + lpeg.P("subsection")
1269 + lpeg.P("subsubsection")) 1269 + lpeg.P("subsubsection"))
1270local par = lpeg.P(lpeg.P("\\par") * spce^1)
1271local parb = lpeg.P(lpeg.Cs("\\p@rb") * spce^1)
1272local para = lpeg.P(lpeg.Cs("\\p@ra") * spce^1)
1270 1273
1271-- Bind to local variables 1274-- Bind to local variables
1272local next = next 1275local next = next
@@ -1747,26 +1750,26 @@ local function envtotei(str)
1747 then 1750 then
1748 -- if envtotags[i].b == "p" 1751 -- if envtotags[i].b == "p"
1749 -- then 1752 -- then
1750 str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1753 -- str = gsub(str, lpeg.P("\\par") * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1751 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1754 -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1752 * bcbracesii * spcenc^-1, 1755 -- * bcbracesii * spcenc^-1,
1753 "\n<"..envtotags[i].b..envtotags[i].c..">") 1756 -- "\n<"..envtotags[i].b..envtotags[i].c..">")
1754 -- else 1757 -- else
1755 -- str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1758 -- str = gsub(str, (lpeg.P("\\par") + lpeg.P("<p>")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1756 -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1759 -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1757 -- * bcbracesii * spcenc^-1, 1760 -- * bcbracesii * spcenc^-1,
1758 -- "</p>\n<"..envtotags[i].b..envtotags[i].c..">") 1761 -- "</p>\n<"..envtotags[i].b..envtotags[i].c..">")
1759 -- end 1762 -- end
1760 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") 1763 -- str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1761 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * (lpeg.P("\\par") + lpeg.P("</p>")), 1764 -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * lpeg.P("\\par"),
1762 "</"..envtotags[i].b..">\n<p>") 1765 -- "</"..envtotags[i].b..">\n")
1763 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1766 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1764 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1767 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
1765 * bcbracesii * spcenc^-1, 1768 * bcbracesii * spcenc^-1,
1766 "<"..envtotags[i].b..envtotags[i].c..">") 1769 "\\p@rb <"..envtotags[i].b..envtotags[i].c..">")
1767 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") 1770 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
1768 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), 1771 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
1769 "</"..envtotags[i].b..">\n<p>") 1772 "</"..envtotags[i].b..">\\p@ra ")
1770 else 1773 else
1771 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") 1774 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
1772 * lpeg.Cs(envtotags[i].a) * lpeg.P("}") 1775 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
@@ -1854,13 +1857,21 @@ end
1854 1857
1855local function partotei(str) 1858local function partotei(str)
1856 str = gsub(str, lpeg.P(lpeg.P("\\par") * spcenc^1)^1, "\\par ") 1859 str = gsub(str, lpeg.P(lpeg.P("\\par") * spcenc^1)^1, "\\par ")
1860 str = gsub(str, ((para + parb) * par^-1)^2, "\\p@r ")
1861 str = string.gsub(str, "\\p@ra%s?", "<p>")
1862 str = string.gsub(str, "\\p@rb%s?", "</p>")
1863 str = string.gsub(str, "\\p@r%s?", "")
1864-- 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 ")
1857 str = string.gsub(str, "%s?\\par%s?", "<p>", 1) 1866 str = string.gsub(str, "%s?\\par%s?", "<p>", 1)
1867 --str = string.gsub(str, "(\\par)(%s-)(%<%/?div%d?)", "%3")
1868 str = string.gsub(str, "(%<p%>)(%s-)(%<%/?div%d?)", "%3")
1858 str = string.gsub(str, "%s?\\par%s?", "</p><p>") 1869 str = string.gsub(str, "%s?\\par%s?", "</p><p>")
1859 str = string.gsub(str, "<p>%s?</p>", "") 1870 str = string.gsub(str, "<p>%s?</p>", "")
1860 str = string.gsub(str, "(%<p%>)%s?(%</div%>)$", "%2") 1871 str = string.gsub(str, "(%<p%>)%s?(%</div%>)$", "%2")
1861 str = string.gsub(str, "(%<p%>)%s?$", "") 1872 str = string.gsub(str, "(%<p%>)%s?$", "")
1862 str = string.gsub(str, "(<p>)%s?(<div.->)", "%2%1") 1873 str = string.gsub(str, "(<p>)%s?(<div.->)", "%2%1")
1863 str = string.gsub(str, "(%<p%>)%s?(<head>.-</head>)", "%2%1") 1874 -- str = string.gsub(str, "(%<p%>)%s?(<head>.-</head>)", "%2%1")
1864 return str 1875 return str
1865end 1876end
1866 1877
@@ -1980,7 +1991,7 @@ local function ekddivs_totei(str)
1980 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end 1991 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
1981 if tein ~= "" then tein = " n=\""..tein.."\"" else end 1992 if tein ~= "" then tein = " n=\""..tein.."\"" else end
1982 if teidepth ~= "" then teidepth = " depth=\""..teidepth.."\"" else end 1993 if teidepth ~= "" then teidepth = " depth=\""..teidepth.."\"" else end
1983 return string.format("\\par <div%s%s%s/><head>%s</head>", 1994 return string.format("<div%s%s%s/><head>%s</head>",
1984 teitype, tein, teidepth, teihead) 1995 teitype, tein, teidepth, teihead)
1985 else 1996 else
1986 return "" 1997 return ""
@@ -1999,7 +2010,7 @@ local function section_totei(str)
1999 else 2010 else
2000 ctr = divdepth[secname] 2011 ctr = divdepth[secname]
2001 arg = string.sub(arg, 2, -2) 2012 arg = string.sub(arg, 2, -2)
2002 return string.format("\\par <div%s type=\"%s\"><head>%s</head>", 2013 return string.format("\\p@rb <div%s type=\"%s\"><head>%s</head>\\p@ra ",
2003 ctr, secname, arg) 2014 ctr, secname, arg)
2004 end 2015 end
2005 end) 2016 end)
@@ -2100,7 +2111,7 @@ local function textotei(str)
2100 str = cmdtotei(str) 2111 str = cmdtotei(str)
2101 str = self_close_tags(str) 2112 str = self_close_tags(str)
2102 str = partotei(str) 2113 str = partotei(str)
2103 str = checkpars(str) 2114-- str = checkpars(str)
2104 if ekddivs 2115 if ekddivs
2105 then 2116 then
2106 else 2117 else