From 9bb459e9fedcad94579973ccd07ad9e78d0734c8 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 19 Feb 2018 19:19:07 +0100 Subject: 2018-02-19 19:05:00 --- tex/context/base/mkiv/lxml-tab.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tex/context/base/mkiv/lxml-tab.lua') diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index cc6ba289a..8d4be58ab 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -448,13 +448,13 @@ local function attribute_specification_error(str) return str end --- these will be set later - --- in order to overcome lua limitations we wrap entity stuff in a --- closure +-- I'm sure that this lpeg can be simplified (less captures) but it evolved ... +-- so i'm not going to change it now. do + -- In order to overcome lua limitations we wrap entity stuff in a closure. + local badentity = "&" -- was "&error;" xml.placeholders = { @@ -1128,7 +1128,7 @@ grammar_unparsed_text_yes = install(space_nl, spacing_nl, anything_nl) -- maybe we will add settings to result as well -local function _xmlconvert_(data,settings) +local function _xmlconvert_(data,settings,detail) settings = settings or { } -- no_root strip_cm_and_dt given_entities parent_root error_handler preparexmlstate(settings) if settings.linenumbers then @@ -1156,6 +1156,8 @@ local function _xmlconvert_(data,settings) nt = 0 if not data or data == "" then errorstr = "empty xml file" + elseif data == true then + errorstr = detail or "problematic xml file" elseif utfize or resolve then local m = lpegmatch(grammar_parsed_text_one,data) if m then @@ -1237,8 +1239,10 @@ local function xmlconvert(data,settings) local ok, result = pcall(function() return _xmlconvert_(data,settings) end) if ok then return result + elseif type(result) == "string" then + return _xmlconvert_(true,settings,result) else - return _xmlconvert_("",settings) + return _xmlconvert_(true,settings) end end -- cgit v1.2.3