Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2021-12-13 13:13:21 +0300
committerThijs Schreijer <thijs@thijsschreijer.nl>2022-01-10 14:25:49 +0300
commit76d789463c28ebf84f806252d00518818e9adc79 (patch)
tree21ca48d950dc9e63ceeeca09ec2dc463cda8dae1 /lua
parent2c4a32dea4c24f185fe5f863867841b8fda3bafb (diff)
minor refactor
Diffstat (limited to 'lua')
-rw-r--r--lua/pl/xml.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 58d2959..860e6b3 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -69,19 +69,29 @@ end
-- @return nil, error the error can either be a file error or a parse error
function _M.parse(text_or_file, is_file, use_basic)
local parser,status,lom
- if use_basic then parser = _M.basic_parse
+ if use_basic then
+ parser = _M.basic_parse
else
status,lom = pcall(require,'lxp.lom')
- if not status then parser = _M.basic_parse else parser = lom.parse end
+ if not status then
+ parser = _M.basic_parse
+ else
+ parser = lom.parse
+ end
end
+
if is_file then
local f,err = io.open(text_or_file)
if not f then return nil,err end
text_or_file = f:read '*a'
f:close()
end
+
local doc,err = parser(text_or_file)
- if not doc then return nil,err end
+ if not doc then
+ return nil,err
+ end
+
if lom then
_M.walk(doc,false,function(_,d)
setmetatable(d,Doc)