Refactor XML parser #82

Merged
thesabinelim merged 10 commits from xml-parser-refactor into master 2023-05-16 21:07:42 +08:00
Showing only changes of commit 4b029c9728 - Show all commits

View File

@@ -28,11 +28,11 @@ local XMLNode = {
} }
local parseAttributes = function(node, s) local parseAttributes = function(node, s)
-- Parse "" style attributes -- Parse "" style string attributes
local _, _ = string.gsub(s, "(%w+)=([\"'])(.-)%2", function(attribute, _, value) local _, _ = string.gsub(s, "(%w+)=([\"'])(.-)%2", function(attribute, _, value)
node:addAttribute(attribute, "\"" .. value .. "\"") node:addAttribute(attribute, "\"" .. value .. "\"")
end) end)
-- Parse {} style attributes -- Parse {} style computed attributes
local _, _ = string.gsub(s, "(%w+)={(.-)}", function(attribute, expression) local _, _ = string.gsub(s, "(%w+)={(.-)}", function(attribute, expression)
node:addAttribute(attribute, expression) node:addAttribute(attribute, expression)
end) end)