diff options
Diffstat (limited to 'tex/context/base/mkiv/lxml-tab.lua')
-rw-r--r-- | tex/context/base/mkiv/lxml-tab.lua | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index edc4e75eb..1f0ec33b1 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -369,8 +369,7 @@ end local function add_text(text) if text == "" then return - end - if cleanup then + elseif cleanup then if nt > 0 then local s = dt[nt] if type(s) == "string" then @@ -1022,6 +1021,7 @@ local function install(spacenewline,spacing,anything) local text_unparsed = Cs((anything-open)^1) local text_parsed = (Cs((anything-open-ampersand)^1)/add_text + Cs(entity_text)/add_text)^1 +-- local text_parsed = ((Cs(((anything-open-ampersand)^1) + entity_text))/add_text)^1 local somespace = (spacenewline)^1 local optionalspace = (spacenewline)^0 @@ -1043,10 +1043,16 @@ local function install(spacenewline,spacing,anything) local unparsedtext = text_unparsed / add_text local balanced = P { "[" * ((anything - S"[]") + V(1))^0 * "]" } -- taken from lpeg manual, () example + -- todo: combine empty and begin so that we scan attributes only once .. maybe also go for match time captures + local emptyelement = (spacing * open * name * attributes * optionalspace * slash * close) / add_empty local beginelement = (spacing * open * name * attributes * optionalspace * close) / add_begin local endelement = (spacing * open * slash * name * optionalspace * close) / add_end +-- local commonelement = spacing * open * name * attributes * optionalspace * +-- local cemptyelement = (slash * close) / add_empty +-- local cbeginelement = ( * close) / add_begin + -- todo: combine the opens in: local begincomment = open * P("!--") @@ -1103,11 +1109,7 @@ local function install(spacenewline,spacing,anything) local publicdoctype = doctypename * somespace * P("PUBLIC") * somespace * value * somespace * value * somespace * doctypeset local systemdoctype = doctypename * somespace * P("SYSTEM") * somespace * value * somespace * doctypeset local simpledoctype = (anything-close)^1 -- * balanced^0 - local somedoctype = C((somespace * ( - -publicentityfile + - - publicdoctype + systemdoctype + definitiondoctype + simpledoctype) * optionalspace)^0) + local somedoctype = C((somespace * (publicentityfile + publicdoctype + systemdoctype + definitiondoctype + simpledoctype) * optionalspace)^0) local instruction = (spacing * begininstruction * someinstruction * endinstruction) / function(...) add_special("@pi@",...) end local comment = (spacing * begincomment * somecomment * endcomment ) / function(...) add_special("@cm@",...) end @@ -1150,6 +1152,16 @@ publicentityfile + children = parsedtext + V("parent") + emptyelement + comment + cdata + instruction + parsedcrap, } +-- local grammar_parsed_text_two = P { "followup", +-- followup = beginelement * V("children")^0 * endelement * trailer, +-- children = parsedtext + beginelement * V("children")^0 * endelement + emptyelement + comment + cdata + instruction + parsedcrap, +-- } + +-- local grammar_parsed_text_two = P { "followup", +-- followup = commonelement * cbeginelement * V("children")^0 * endelement * trailer, +-- children = parsedtext + commonelement * (cbeginelement * V("children")^0 * endelement + cemptyelement) + comment + cdata + instruction + parsedcrap, +-- } + local grammar_unparsed_text = P { "preamble", preamble = utfbom^0 * instruction^0 * (doctype + comment + instruction)^0 * V("parent") * trailer, parent = beginelement * V("children")^0 * endelement, |