Skip to content

Commit

Permalink
Fix bugs in Lua scripts surfaced by Luacheck
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 29, 2024
1 parent d6ce50d commit d7aa0a0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions data/creole.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ local function ListItem(lev, ch)
end

-- Grammar
G = P{ "Doc",
local grammar = P{ "Doc",
Doc = Ct(V"Block"^0)
/ pandoc.Pandoc ;
Block = blankline^0
Expand Down Expand Up @@ -186,5 +186,5 @@ G = P{ "Doc",
}

function Reader(input, reader_options)
return lpeg.match(G, tostring(input))
return lpeg.match(grammar, tostring(input))
end
8 changes: 4 additions & 4 deletions pandoc-lua-engine/test/lua/module/pandoc-list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ return {

group 'new' {
test('make table usable as list', function ()
local test = List:new{1, 1, 2, 3, 5}
local out = List:new{1, 1, 2, 3, 5}
assert.are_same(
{1, 1, 4, 9, 25},
test:map(function (x) return x^2 end)
out:map(function (x) return x^2 end)
)
end),
test('return empty list if no argument is given', function ()
assert.are_same({}, List:new())
end),
test('metatable of result is pandoc.List', function ()
local test = List:new{5}
assert.are_equal(List, getmetatable(test))
local out = List:new{5}
assert.are_equal(List, getmetatable(out))
end)
},

Expand Down
4 changes: 2 additions & 2 deletions tools/moduledeps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ end

if not (mode == "tree" or mode == "transitive") then
io.write("Usage: lua moduledeps (tree|transitive) modulename\n")
io.exit(1)
os.exit(1)
end

if #roots == 0 then
io.write("Usage: lua moduledeps modulename+\n")
io.exit(1)
os.exit(1)
end

for line in lines do
Expand Down
6 changes: 3 additions & 3 deletions tools/update-lua-module-docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ local function render_type (name, level, modulename)
if next(metatable.methods) then
local attr = {'type-' .. id .. '-methods'}
methods:insert(Header(level + 1, "Methods", attr))
for _, method in sorted(metatable.methods) do
-- attr = {'type-' .. modulename .. '.' .. name .. '.' .. name}
-- methods:insert(Header(level + 2, name, attr))
for propname, method in sorted(metatable.methods) do
-- attr = {'type-' .. modulename .. '.' .. name .. '.' .. propname}
-- methods:insert(Header(level + 2, propname, attr))
methods:extend(render_function(documentation(method), level+2, id))
end
end
Expand Down

0 comments on commit d7aa0a0

Please sign in to comment.