Skip to content

Commit

Permalink
Merge pull request #2190 from alerque/xml
Browse files Browse the repository at this point in the history
Cleanup XML input before processing
  • Loading branch information
alerque authored Dec 7, 2024
2 parents f8b984d + 4bb31f0 commit c3fdfcc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions inputters/xml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ inputter._name = "xml"
inputter.order = 2

local function startcommand (parser, command, options)
-- Discard list values (non-key/value), stuffed by LXP/expat to make it possible to deduce the order of keys in
-- the source. We're not using it, so we don't care and it is clutter in the AST that makes it different from
-- ASTs generated from SIL inputs.
for i = 1, #options do
options[i] = nil
end
local stack = parser:getcallbacks().stack
local lno, col, pos = parser:pos()
local position = { lno = lno, col = col, pos = pos }
Expand Down
5 changes: 5 additions & 0 deletions inputters/xml_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ describe("#XML #inputter", function ()
assert.is.equal("bar", t[1])
end)

it("commands should parse only named arguments", function ()
local t = inputter:parse([[<foo baz="qiz">bar</foo>]])[1][1]
assert.is.equal(0, #t.options)
end)

-- it("commands with quoted arg with escape", function()
-- local t = inputter:parse([[<foo baz="qiz \"qiz\"">bar</bar>]])
-- assert.is.equal("foo", t.command)
Expand Down

0 comments on commit c3fdfcc

Please sign in to comment.