Skip to content

Commit 3436c10

Browse files
committed
refactor!: Remove silex compatibility layer and some SILE shims
Stop supporting older SILE 0.14.x and 0.15.x (x <= 12). Remove dependency on the silex compatibility layer. Remove some compatibility fallbacks for earlier versions of SILE. Update in-code documentation to LDoc (rather than the VSCode thing).
1 parent 7ccd74b commit 3436c10

File tree

16 files changed

+193
-161
lines changed

16 files changed

+193
-161
lines changed

.gitignore

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,19 @@ luac.out
4242
# SILE artifacts
4343
*.toc
4444
*.ref
45-
tests/*.pdf
46-
tests/*.debug
45+
*.pdf
46+
*.idx
47+
*.debug
48+
**/converted/*
49+
**/embedded/*
4750

4851
# I often have crappy test files here
4952
temp/*
5053

54+
# LDoc if ran locally
55+
doc/*
56+
ldoc/*
57+
58+
# Stuff copied or linked from lua_libraries/ to sile/
59+
# for hacking (as those files from lua_libraries/ are not in the sile namespace)
60+
sile/*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For casual readers, this collection notably aims at easily converting Djot or Ma
1515

1616
## Installation
1717

18-
This module collection requires SILE v0.14 or upper (recommended: v0.15.10).
18+
This module collection requires SILE v0.15 (recommended: v0.15.13).
1919

2020
Installation relies on the **luarocks** package manager.
2121

examples/introduction.dj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Yet, these options remain available under the hood for those seeking a blend of
2828

2929
### Standard installation
3030

31-
This module collection requires SILE v0.14 (recommended: v0.15.10 or upper).
31+
This module collection requires SILE v0.15 (recommended: v0.15.13).
3232

3333
Installation relies on the *luarocks* package manager.
3434
To install the latest version, you may use the provided “rockspec”:

examples/markdown-djot.bib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ @book{sile
22
title = {The SILE Book},
33
author = {Cozens, Simon and Maclennan, Caleb and Nicole, Olivier and Willis, Didier},
44
year = {2025},
5-
edition = {version 0.15.10},
5+
edition = {version 0.15.13},
66
}
77

88
@book{sile:willis2021,

examples/sile-and-markdown-manual.silm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
- Pandoc
1111
authors: Didier Willis
1212
publisher: Omikhleia
13-
pubdate: 2025-03-21
13+
pubdate: 2025-08-29
1414
url: https://github.com/Omikhleia/markdown.sile
1515
copyright: © 2022–2025, Didier Willis.
1616
legal: |
@@ -44,7 +44,6 @@ sile:
4444
packages:
4545
- autodoc-resilient # REQUIRED FOR RESILIENT, do not use regular autodoc
4646
- dropcaps
47-
- resilient.defn
4847
- resilient.poetry
4948
content:
5049
chapters:

inputters/djot.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
-- @copyright License: MIT (c) 2023-2024 Omikhleia, Didier Willis
77
-- @module inputters.djot
88
--
9-
require("silex.ast") -- Compatibility layer
10-
119
local utils = require("packages.markdown.utils")
1210
local createCommand, createStructuredCommand
1311
= SU.ast.createCommand, SU.ast.createStructuredCommand
@@ -149,7 +147,7 @@ function Renderer:render_children (node)
149147
error("Djot content too deeply nested", 2)
150148
elseif err:find("paperSize") then
151149
-- HACK
152-
-- SILE 0.14.16 is still unimaginative how to avoid crashing the outputter
150+
-- SILE 0.15.13 is still unimaginative how to avoid crashing the outputter
153151
-- and SU.error raises another error in the process.
154152
SILE.scratch.caughterror = true
155153
error("", 2)

inputters/markdown.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
-- @copyright License: MIT (c) 2022-2024 Omikhleia, Didier Willis
66
-- @module inputters.markdown
77
--
8-
require("silex.ast")
9-
108
local utils = require("packages.markdown.utils")
119
local createCommand, createStructuredCommand
1210
= SU.ast.createCommand, SU.ast.createStructuredCommand

inputters/pandocast.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
-- @copyright License: MIT (c) 2022-2024 Omikhleia, Didier Willis
1313
-- @module inputters.pandocast
1414
--
15-
require("silex.ast") -- Compatibility layer
16-
1715
local utils = require("packages.markdown.utils")
1816
local createCommand, createStructuredCommand
1917
= SU.ast.createCommand, SU.ast.createStructuredCommand

packages/djot/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--- Djot native support for SILE
22
--
33
-- @copyright License: License: MIT (c) 2023 Omikhleia
4-
-- @module packages.djot
4+
-- @classmod packages.djot
55
--
66
local base = require("packages.base")
77

packages/markdown/cmbase.lua

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
---A base class for markdown command packages.
22
--
3+
-- Derived from SILE's `packages.base`.
4+
--
35
-- It abstracts the low-level details of feature detection and compatibility with resilient components.
46
-- So the markdown.command packages can focus on their specific features and commands.
57
--
8+
--
69
-- @copyright License: MIT (c) 2024 Omikhleia, Didier Willis
7-
-- @module packages.markdown.cmbase
10+
-- @classmod packages.markdown.cmbase
811
--
9-
1012
local base = require("packages.base")
1113

1214
local package = pl.class(base)
@@ -16,9 +18,9 @@ package._name = "markdown.cmbase"
1618
-- NOTE: The previous implementation was clever;
1719
-- local ok, ResilientBase = pcall(require, 'classes.resilient.base')
1820
-- return ok and self.class:is_a(ResilientBase)
19-
-- However this *loads* the class, which loads all the silex extensions, even if
21+
-- However this *loads* the class, which loads all the SILE redefinitions, even if
2022
-- the class is not actually used...
21-
-- Enforcing the silex extensions is not what we wanted.
23+
-- Enforcing resilient's SILE overrides is not what we wanted (for now).
2224
-- So we are back to a more naive implementation, checking the class hierarchy
2325
-- by name. This is perhaps lame and knows too much about internals, but heh.
2426
local function isResilientClass (cl)
@@ -33,8 +35,10 @@ local function isResilientClass (cl)
3335
end
3436

3537
--- Load a package with a resilient variant.
36-
---@param resilientpack string The resilient package name.
37-
---@param legacypack string The legacy package name.
38+
-- In a resilient context, the resilient variant is loaded.
39+
-- Otherwise, the legacy variant is loaded.
40+
-- @tparam string resilientpack The resilient package name.
41+
-- @tparam string legacypack The legacy package name.
3842
function package:loadAltPackage (resilientpack, legacypack)
3943
if not self.class.packages[resilientpack] then
4044
-- In resilient context, try enforcing the use of resilient variants,
@@ -48,17 +52,23 @@ function package:loadAltPackage (resilientpack, legacypack)
4852
end
4953
end
5054

51-
--- Load an optional package if present
52-
---@param pack string The package name.
55+
--- Load an optional package, if available.
56+
-- @tparam string pack string The package name.
5357
function package:loadOptPackage (pack)
5458
local ok, _ = pcall(function () return self:loadPackage(pack) end)
5559
SU.debug("markdown.commands", "Optional package "..pack.. (ok and " loaded" or " not loaded"))
5660
end
5761

58-
--- Feature detection, so we can see e.g. with self.hasPackageSupport.xxx if
59-
--- a package is supported or not.
60-
---@param check function The feature detection function.
61-
---@return table The proxy object.
62+
--- (Internal) Feature detection proxy creation.
63+
-- Such proxy objects are used to implement:
64+
--
65+
-- - self.hasPackageSupport.xxx
66+
-- - self.hasCommandSupport.yyy
67+
-- - self.hasStyleSupport.zzz
68+
--
69+
-- So as to check if a package, command or style is supported or not.
70+
---@tparam function check The feature detection function.
71+
---@treturn table The proxy object.
6272
function package:_createSupportProxy (check)
6373
return setmetatable({}, {
6474
__index = check,
@@ -68,7 +78,8 @@ function package:_createSupportProxy (check)
6878
})
6979
end
7080

71-
--- Package initialization.
81+
--- (Contructor) Package initialization.
82+
-- @tparam table _ Package options (not used here).
7283
function package:_init (_)
7384
base._init(self)
7485

@@ -115,12 +126,16 @@ function package:_init (_)
115126
end)
116127
end
117128

118-
function package:registerCommand(name, func, help, pack)
129+
--- (Override) Register a command.
130+
-- It overrides the default package command registration, and tweaks known options.
131+
-- Typically, width and height in percentage are replaced by line and frame relative
132+
-- units, respectively, for compatibility with SILE units.
133+
-- @tparam string name Name of the command to register
134+
-- @tparam function func Command implementation function
135+
-- @tparam[opt] string help Short help string
136+
function package:registerCommand(name, func, help)
119137
local tweakCommandWithKnownOptions = function (options, content)
120138
options = options or {}
121-
-- Tweak known options to be compatible with SILE units.
122-
-- width and height in percentage are replaced by line and frame relative
123-
-- units, respectively.
124139
if options.width and type(options.width) == "string" then
125140
options.width = options.width:gsub("%%$", "%%lw")
126141
end
@@ -129,16 +144,22 @@ function package:registerCommand(name, func, help, pack)
129144
end
130145
return func(options, content)
131146
end
132-
base.registerCommand(self, name, tweakCommandWithKnownOptions, help, pack)
147+
base.registerCommand(self, name, tweakCommandWithKnownOptions, help)
133148
end
134149

135150
--- Register a style (as in resilient packages).
151+
-- For subclasses defining custom styles, this method is supposed to be used
152+
-- in an overridden registerStyles() method, so that the style is registered
153+
-- only in the resilient context.
154+
-- @tparam string name Style name
155+
-- @tparam table opts Style options
156+
-- @tparam table styledef Style definition
136157
function package:registerStyle (name, opts, styledef)
137158
return self.styles:defineStyle(name, opts, styledef, self._name)
138159
end
139160

140-
--- Register styles (as in resilient packages)
141-
--- For overriding in subclass
161+
--- (Abstract) Register styles (as in resilient packages).
162+
-- For overriding in subclasses.
142163
function package.registerStyles (_) end
143164

144165
package.documentation = [[\begin{document}

0 commit comments

Comments
 (0)