From a71357a231c4061abea1074567cbf52a4cd58a24 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Fri, 8 Dec 2023 15:28:09 +0100 Subject: [PATCH 1/6] chore: Update Luacheck CI action and check for minimum Lua version Co-authored-by: Caleb Maclennan --- .github/workflows/luacheck.yml | 4 ++-- .luacheckrc | 17 ++--------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml index e4576b7..9cb784c 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@v3 + uses: actions/checkout@v4 - name: Luacheck - uses: lunarmodules/luacheck@v0 + uses: lunarmodules/luacheck@v1 diff --git a/.luacheckrc b/.luacheckrc index a5d3578..0261183 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,17 +1,13 @@ -std = "max" +std = "min+sile" include_files = { "**/*.lua", - "sile.in", "*.rockspec", ".busted", ".luacheckrc" } exclude_files = { - "benchmark-*", - "compare-*", - "sile-*", "lua_modules", - "lua-libraries", + -- "lua-libraries", ".lua", ".luarocks", ".install" @@ -19,15 +15,6 @@ exclude_files = { files["**/*_spec.lua"] = { std = "+busted" } -globals = { - "SILE", - "SU", - "luautf8", - "pl", - "fluent", - "SYSTEM_SILE_PATH", - "SHARED_LIB_EXT" -} max_line_length = false ignore = { "581" -- operator order warning doesn't account for custom table metamethods From e42cdc9734e94dcba6cfd38789848373534fb5d6 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Wed, 27 Dec 2023 19:30:39 +0100 Subject: [PATCH 2/6] chore(lunarmark): Update lunamark to master as of Sept. 27, 2023 Fixes some minor code and linting errors that were fixed when our PRs to the upstream lunamark library were reviewed. --- lua-libraries/lunamark/reader/markdown.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lua-libraries/lunamark/reader/markdown.lua b/lua-libraries/lunamark/reader/markdown.lua index 1fd35a0..5a9dc37 100644 --- a/lua-libraries/lunamark/reader/markdown.lua +++ b/lua-libraries/lunamark/reader/markdown.lua @@ -166,7 +166,7 @@ parsers.attrvalue = (parsers.dquote * parsers.squote) + C((parsers.anyescaped - parsers.dquote - parsers.space - P("}"))^1) -parsers.attrpair = Cg(C((parsers.attrid)^1) +parsers.attrpair = Cg(C(parsers.attrid) * parsers.optionalspace * parsers.equal * parsers.optionalspace * parsers.attrvalue) * parsers.optionalspace^-1 @@ -1221,12 +1221,11 @@ function M.new(writer, options) parsers.doubletildes) ) / writer.strikeout - larsers.Mark - = ( parsers.between(parsers.Inline, parsers.doubleequals, - parsers.doubleequals) - ) / function (inlines, x, y) - return writer.span(inlines, { class="mark" }) - end + larsers.Mark = parsers.between(parsers.Inline, parsers.doubleequals, + parsers.doubleequals) + / function (inlines) + return writer.span(inlines, { class="mark" }) + end larsers.Span = ( parsers.between(parsers.Inline, parsers.lbracket, parsers.rbracket) ) * ( parsers.attributes ) @@ -1402,7 +1401,8 @@ function M.new(writer, options) larsers.Blockquote = Cs((((parsers.leader * parsers.more * parsers.space^-1)/"" * parsers.linechar^0 * parsers.newline)^1 * (-(parsers.leader * parsers.more - + parsers.blankline + larsers.fenced_div_out) * parsers.linechar^1 + + parsers.blankline + + larsers.fenced_div_out) * parsers.linechar^1 * parsers.newline)^0 * parsers.blankline^0 )^1) / parse_blocks / writer.blockquote From c9d7bed85f87ee781ea498f31f4dfa308c2e3e5c Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Wed, 27 Dec 2023 19:47:55 +0100 Subject: [PATCH 3/6] chore(djot): Comment out an unused table --- lua-libraries/djot/json.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua-libraries/djot/json.lua b/lua-libraries/djot/json.lua index e17996f..83473fa 100644 --- a/lua-libraries/djot/json.lua +++ b/lua-libraries/djot/json.lua @@ -40,10 +40,13 @@ local escape_char_map = { [ "\t" ] = "t", } -local escape_char_map_inv = { [ "/" ] = "/" } -for k, v in pairs(escape_char_map) do - escape_char_map_inv[v] = k -end +-- BEGIN EXTENSION DIDIER 20231227 +-- This escape_char_map_inv is not used... +-- local escape_char_map_inv = { [ "/" ] = "/" } +-- for k, v in pairs(escape_char_map) do +-- escape_char_map_inv[v] = k +-- end +-- END EXTENSION DIDIER 20231227 local function escape_char(c) From ee1f5e55dc25e635599ede4525d53f8923105959 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Wed, 27 Dec 2023 19:49:19 +0100 Subject: [PATCH 4/6] fix: Use Lua 5.1 compatible luautf8 interface Global luautf8 module is guaranteed to be provided by SILE. Co-authored-by: Caleb Maclennan --- inputters/markdown.lua | 2 +- inputters/pandocast.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inputters/markdown.lua b/inputters/markdown.lua index a395dca..c1ac0bb 100644 --- a/inputters/markdown.lua +++ b/inputters/markdown.lua @@ -53,7 +53,7 @@ local function extractLineBlockLevel (inlines) if f and type(f) == "string" then local line = f line = line:gsub("^[ ]+", function (match) -- Warning, U+00A0 here. - level = utf8.len(match) + level = luautf8.len(match) return "" end) if line == "" then -- and #inlines == 1 then diff --git a/inputters/pandocast.lua b/inputters/pandocast.lua index 95b18d2..cc982a3 100644 --- a/inputters/pandocast.lua +++ b/inputters/pandocast.lua @@ -157,7 +157,7 @@ local function extractLineBlockLevel (inlines) -- Or any other inline content if there are not leading spaces. local line = f.c line = line:gsub("^[ ]+", function (match) -- Warning, U+00A0 here. - level = utf8.len(match) + level = luautf8.len(match) return "" end) f.c = line -- replace From eb8984b8afa3341b76027935bd342f8fcc32c036 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Wed, 27 Dec 2023 20:29:18 +0100 Subject: [PATCH 5/6] chore: Enforce minimal linting on vendored libraries In order for us not to add too much bad code when implementing our modifications or extensions... --- .luacheckrc | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index 0261183..7420f84 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -7,14 +7,60 @@ include_files = { } exclude_files = { "lua_modules", - -- "lua-libraries", ".lua", ".luarocks", ".install" } +globals = { + -- acceptable as SILE has the necessary compatibility shims: + -- pl.utils.unpack provides extra functionality and nil handling + -- but our modules shouldn't be using that anyway. + "table.unpack" +} files["**/*_spec.lua"] = { std = "+busted" } +-- Vendored libraries with our modifications and/or extensions: +-- We want to ensure a minimal level of decent linting on these files +-- in order to avoid the worst mistakes when modifying them. +files["lua-libraries/lunamark"] = { + globals = { + -- used in compatibility shims and feature detection + "loadstring", + "setfenv", + "unpack", + "utf8", + }, +} +files["lua-libraries/djot.lua"] = { + globals = { + -- used in compatibility shims and feature detection + "unpack", + }, + ignore = { + -- -- matter of taste and not harmful + "211", -- unused function / unused variable + "212", -- unused argument + } +} +files["lua-libraries/djot"] = { + globals = { + -- used in compatibility shims and feature detection + "loadstring", + "unpack", + "utf8", + }, + ignore = { + -- usually bad but used in compatiblity shims... + "121", -- setting a read-only global variable + -- usually questionable but weird use in constructors... + "312", -- value of argument self is overwritten before use + -- matter of taste and not harmful + "211", -- unused function / unused variable + "212", -- unused argument + "213", -- unused loop variable + } +} max_line_length = false ignore = { "581" -- operator order warning doesn't account for custom table metamethods From 27a3e193790c4cfa1ed19bbe04ef299b00f81912 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Thu, 28 Dec 2023 10:57:45 +0100 Subject: [PATCH 6/6] chore: Update rockspec for v1.5.1 --- markdown.sile-1.5.1-1.rockspec | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 markdown.sile-1.5.1-1.rockspec diff --git a/markdown.sile-1.5.1-1.rockspec b/markdown.sile-1.5.1-1.rockspec new file mode 100644 index 0000000..f41e5ca --- /dev/null +++ b/markdown.sile-1.5.1-1.rockspec @@ -0,0 +1,60 @@ +rockspec_format = "3.0" +package = "markdown.sile" +version = "1.5.1-1" +source = { + url = "git+https://github.com/Omikhleia/markdown.sile.git", + tag = "v1.5.1", +} +description = { + summary = "Native Markdown support for the SILE typesetting system.", + detailed = [[ + This package set for the SILE typesetting system provides a complete redesign + of the native Markdown support for SILE, with a great set of Pandoc-like + extensions and plenty of extra goodies. + ]], + homepage = "https://github.com/Omikhleia/markdown.sile", + license = "MIT", +} +dependencies = { + "lua >= 5.1", + "embedders.sile >= 0.1.0", + "labelrefs.sile >= 0.1.0", + "ptable.sile >= 2.0.2", + "smartquotes.sile >= 1.0.0", + "textsubsuper.sile >= 1.1.1", + "silex.sile >= 0.3.0", +} + +build = { + type = "builtin", + modules = { + ["sile.classes.markdown"] = "classes/markdown.lua", + ["sile.inputters.markdown"] = "inputters/markdown.lua", + ["sile.inputters.pandocast"] = "inputters/pandocast.lua", + ["sile.inputters.djot"] = "inputters/djot.lua", + ["sile.packages.markdown"] = "packages/markdown/init.lua", + ["sile.packages.markdown.commands"] = "packages/markdown/commands.lua", + ["sile.packages.markdown.utils"] = "packages/markdown/utils.lua", + ["sile.packages.pandocast"] = "packages/pandocast/init.lua", + ["sile.packages.djot"] = "packages/djot/init.lua", + + ["sile.lunamark"] = "lua-libraries/lunamark.lua", + ["sile.lunamark.entities"] = "lua-libraries/lunamark/entities.lua", + ["sile.lunamark.reader"] = "lua-libraries/lunamark/reader.lua", + ["sile.lunamark.reader.markdown"] = "lua-libraries/lunamark/reader/markdown.lua", + ["sile.lunamark.util"] = "lua-libraries/lunamark/util.lua", + ["sile.lunamark.writer"] = "lua-libraries/lunamark/writer.lua", + ["sile.lunamark.writer.generic"] = "lua-libraries/lunamark/writer/generic.lua", + ["sile.lunamark.writer.html"] = "lua-libraries/lunamark/writer/html.lua", + ["sile.lunamark.writer.html5"] = "lua-libraries/lunamark/writer/html5.lua", + + ["sile.djot"] = "lua-libraries/djot.lua", + ["sile.djot.attributes"] = "lua-libraries/djot/attributes.lua", + ["sile.djot.json"] = "lua-libraries/djot/json.lua", + ["sile.djot.block"] = "lua-libraries/djot/block.lua", + ["sile.djot.inline"] = "lua-libraries/djot/inline.lua", + ["sile.djot.html"] = "lua-libraries/djot/html.lua", + ["sile.djot.ast"] = "lua-libraries/djot/ast.lua", + ["sile.djot.filter"] = "lua-libraries/djot/filter.lua", + } +}