Skip to content

Commit

Permalink
feat(inputs): Allow (escaped) quote mark in quoted command options
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jul 13, 2020
1 parent f08582a commit 2e9d1b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/inputs-texlike.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ SILE.inputs.TeXlike.parser = function (_ENV)
local sep = S",;" * _
local eol = S"\r\n"
local quote = P'"'
local quotedString = quote * C((1-quote)^1) * quote
local escaped_quote = B(P"\\") * quote
local unescapeQuote = function (str) local a = str:gsub('\\"', '"'); return a end
local quotedString = quote * C(((1-quote+escaped_quote)^1)/unescapeQuote) * quote
local value = quotedString + (1-S",;]")^1
local myID = C(SILE.inputs.TeXlike.identifier + S"{}\\%") / 1
local pair = Cg(myID * _ * "=" * _ * C(value)) * sep^-1 / function (...) local tbl = {...}; return tbl[1], tbl[#tbl] end
Expand Down
6 changes: 6 additions & 0 deletions spec/texlike_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ describe("#TeXlike #input", function ()
assert.is.equal("bar", t[1][1])
end)

it("command with quoted arg with escape", function()
local t = toTree([[\foo[baz="qiz \"qiz\""]{bar}]])
assert.is.equal("qiz \"qiz\"", t.options.baz)
assert.is.equal("bar", t[1][1])
end)

end)

0 comments on commit 2e9d1b5

Please sign in to comment.