aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ekdosis.dtx29
1 files changed, 24 insertions, 5 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index c244e32..f69d083 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1173,6 +1173,7 @@ local function gsub(s, patt, repl)
1173end 1173end
1174 1174
1175-- some basic patterns: 1175-- some basic patterns:
1176local letters = lpeg.R("az", "AZ")
1176local ascii = lpeg.R("az", "AZ", "@@") 1177local ascii = lpeg.R("az", "AZ", "@@")
1177local dblbkslash = lpeg.Cs("\\") 1178local dblbkslash = lpeg.Cs("\\")
1178local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" } 1179local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" }
@@ -1996,17 +1997,35 @@ local aligned_texts = {}
1996local texts_w_apparatus = {} 1997local texts_w_apparatus = {}
1997local coldata_totei = {} 1998local coldata_totei = {}
1998 1999
2000local function sanitize_envdata(str) -- look for a better way to achieve this
2001 str = string.gsub(str, "(%a+)%s+(%b[])", "%1%2")
2002 str = string.gsub(str, "(%a+)(%b[])%s+", "%1%2")
2003 str = string.gsub(str, "%s+(%a+)(%b[])", "%1%2")
2004 str = gsub(str, lpeg.Cs(letters^1)
2005 * spcenc^-1
2006 * -bsqbrackets
2007 * lpeg.Cs(";"), "%1[]%2")
2008 str = string.gsub(str, "%s+(%a+)(%b[])", "%1%2")
2009 return str
2010end
2011
1999function ekdosis.mkenvdata(str, opt) 2012function ekdosis.mkenvdata(str, opt)
2000 str = str ..";" 2013 if not string.find(str, "%;", -1) then str = str .. ";" else end
2001 str = string.gsub(str, "%s+", "") 2014 -- str = str ..";"
2015 -- str = string.gsub(str, "%s+", "")
2002 local fieldstart = 1 2016 local fieldstart = 1
2003 local col = 0 2017 local col = 0
2004 if opt == "texts" then 2018 if opt == "texts" then
2019 str = sanitize_envdata(str)
2005 repeat 2020 repeat
2006 local nexti = string.find(str, "%;", fieldstart) 2021 local _s, nexti = string.find(str, "%b[]%s-%;", fieldstart)
2007 table.insert(aligned_texts, { text = string.sub(str, fieldstart, nexti-1), 2022 local namediv = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%1")
2023 local attr = string.gsub(string.sub(str, fieldstart, nexti-1), "(%a+)%s-(%b[])", "%2")
2024 attr = string.sub(attr, 2, -2)
2025 table.insert(aligned_texts, { text = namediv,
2026 attribute = attr,
2008 column = col }) 2027 column = col })
2009 table.insert(coldata_totei, { environment = string.sub(str, fieldstart, nexti-1), 2028 table.insert(coldata_totei, { environment = namediv,
2010 data = {} }) 2029 data = {} })
2011 col = col + 1 2030 col = col + 1
2012 fieldstart = nexti + 1 2031 fieldstart = nexti + 1