diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml index 9cb784c..e4576b7 100644 --- a/.github/workflows/luacheck.yml +++ b/.github/workflows/luacheck.yml @@ -8,6 +8,6 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Luacheck - uses: lunarmodules/luacheck@v1 + uses: lunarmodules/luacheck@v0 diff --git a/.luacheckrc b/.luacheckrc index 70e3195..a5d3578 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,4 +1,4 @@ -std = "min+sile" +std = "max" include_files = { "**/*.lua", "sile.in", @@ -11,6 +11,7 @@ exclude_files = { "compare-*", "sile-*", "lua_modules", + "lua-libraries", ".lua", ".luarocks", ".install" @@ -18,13 +19,14 @@ exclude_files = { files["**/*_spec.lua"] = { std = "+busted" } -files["lua-libraries"] = { - -- matter of taste and not harmful - ignore = { - "211", -- unused function / unused variable - "212/self", -- unused argument self - "412", --variable was previously defined as an argument - } +globals = { + "SILE", + "SU", + "luautf8", + "pl", + "fluent", + "SYSTEM_SILE_PATH", + "SHARED_LIB_EXT" } max_line_length = false ignore = { diff --git a/inputters/silm.lua b/inputters/silm.lua index 2bda4d0..2435d22 100644 --- a/inputters/silm.lua +++ b/inputters/silm.lua @@ -578,7 +578,7 @@ function inputter:parse (doc) end -- Document wrap-up - local options = sile.options or {} + local options = master.sile.options or {} local classopts = isRoot and { class = options.class or "resilient.book", -- Sane default. We Are Resilient. papersize = options.papersize, diff --git a/lua-libraries/README.tinyyaml b/lua-libraries/README.tinyyaml index a70d773..9af1448 100644 --- a/lua-libraries/README.tinyyaml +++ b/lua-libraries/README.tinyyaml @@ -1,5 +1,6 @@ The "vendored" version of tinyyaml used here is: -https://github.com/api7/lua-tinyyaml (0.4.4 rockspec) +https://github.com/api7/lua-tinyyaml (0.4.3 rockspec at the time of initial +import) It's a fork from: https://github.com/peposso/lua-tinyyaml (which had a 1.0 rockspec earlier) @@ -17,5 +18,3 @@ RESILIENT was to avoid a C binding dependency, since style files are reasonably small theoretically (so performance do not really matter) and only need a subset of YAML (so a pure-Lua implementation, even possibly incomplete, ought to be sufficient.) - -Modications are marked with comments MODIFIED RESILIENT diff --git a/lua-libraries/resilient-tinyyaml.lua b/lua-libraries/resilient-tinyyaml.lua index 0dc2c53..85bec40 100644 --- a/lua-libraries/resilient-tinyyaml.lua +++ b/lua-libraries/resilient-tinyyaml.lua @@ -107,7 +107,7 @@ function types.timestamp:__init(y, m, d, h, i, s, f, z) self.minute = tonumber(i or 0) self.second = tonumber(s or 0) if type(f) == 'string' and sfind(f, '^%d+$') then - self.fraction = tonumber(f) * 10^(3 - #f) -- MODIFIED RESILIENT Lua min compat + self.fraction = tonumber(f) * math.pow(10, 3 - #f) elseif f then self.fraction = f else @@ -611,10 +611,8 @@ function Parser:parseseq(line, lines, indent) error("did not find expected alphabetic or numeric character") elseif rest then -- Array entry with a value - local nextline = lines[1] - local indent2 = countindent(nextline) tremove(lines, 1) - tinsert(seq, self:parsescalar(rest, lines, indent2)) + tinsert(seq, self:parsescalar(rest, lines)) end end return seq @@ -775,11 +773,6 @@ end -- : (list)->dict function Parser:parsedocuments(lines) lines = compactifyemptylines(lines) - -- BEGIN MODIFIED RESILIENT - if #lines == 0 then - return {} - end - -- END MODIFIED RESILIENT if sfind(lines[1], '^%%YAML') then tremove(lines, 1) end diff --git a/packages/resilient/bookmatters/init.lua b/packages/resilient/bookmatters/init.lua index 0bc6248..c6d098b 100644 --- a/packages/resilient/bookmatters/init.lua +++ b/packages/resilient/bookmatters/init.lua @@ -77,11 +77,7 @@ end -- Source: https://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx local function weightedColorDistanceIn3D (color) - return math.sqrt( - (color.r * 255)^2 * 0.241 - + (color.g * 255)^2 * 0.691 - + (color.b * 255)^2 * 0.068 - ) + return math.sqrt(math.pow(color.r * 255, 2) * 0.241 + math.pow(color.g * 255, 2) * 0.691 + math.pow(color.b * 255, 2) * 0.068) end local function contrastColor(color) if not color.r then @@ -164,6 +160,7 @@ function package:registerCommands () end if metadata["meta:isbn"] then + -- local H = SILE.measurement("100%fh"):tonumber() - SILE.measurement("40mm"):tonumber() SILE.call("skip", { height = offset }) SILE.call("kern", { width = SILE.nodefactory.hfillglue() }) SILE.call("framebox", { fillcolor = "white", padding = pad1, borderwidth = 0 }, { diff --git a/packages/resilient/poetry/init.lua b/packages/resilient/poetry/init.lua index 8cf96b2..a44baf8 100644 --- a/packages/resilient/poetry/init.lua +++ b/packages/resilient/poetry/init.lua @@ -5,7 +5,6 @@ -- local ast = require("silex.ast") local createStructuredCommand = ast.createStructuredCommand -local LOG10 = math.log(10) local base = require("packages.resilient.base") @@ -179,8 +178,7 @@ function package:registerCommands () digitSize = SILE.shaper:measureChar("0").width end) local setback = SILE.length("1.75em"):absolute() - local logv = math.floor(math.log(nVerse + iVerse) / LOG10) -- Reminder: math.log10 is not in Lua "min" profiile - indent = SILE.length((logv + 1) * digitSize):absolute() + indent = SILE.length((math.floor(math.log10(nVerse + iVerse)) + 1) * digitSize):absolute() + setback + SILE.length(SILE.settings:get("document.parindent")):absolute() end diff --git a/packages/resilient/styles/init.lua b/packages/resilient/styles/init.lua index 4eecce2..2a2e687 100644 --- a/packages/resilient/styles/init.lua +++ b/packages/resilient/styles/init.lua @@ -563,14 +563,14 @@ function package:registerCommands () local hbox = SILE.typesetter:makeHbox(function () SILE.call("style:apply", { name = name }, { text }) end) - if hbox.width:tonumber() < 0 then + if hbox.width < 0 then SU.warn("Negative hbox width should not occur any more, please report an issue") end - local remainingSpace = hbox.width:tonumber() < 0 and -hbox.width or -beforekern:absolute() - hbox.width + local remainingSpace = hbox.width < 0 and -hbox.width or -beforekern:absolute() - hbox.width -- We want at least the space of a figure digit between the number -- and the text. - if remainingSpace:tonumber() - SILE.length("1nspc"):tonumber() <= 0 then + if remainingSpace:tonumber() - SILE.length("1nspc"):absolute() <= 0 then -- It's not the case, the number goes beyond the available space. -- So add a fixed interword space after it. SILE.call("style:apply", { name = name }, { text })