Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Compatibility upgrade with SILE 0.15 #4

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/fancytoc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
-- Only processes 2 levels, e.g. parts (level 0) and chapters (level 1)
-- and display them as some braced content.
--
require("silex.types") -- Compatibility shims

local base = require("packages.base")

local package = pl.class(base)
Expand Down Expand Up @@ -91,8 +93,8 @@ function package:registerCommands ()
end

SILE.settings:temporarily(function()
SILE.settings:set("current.parindent", SILE.nodefactory.glue())
SILE.settings:set("document.parindent", SILE.nodefactory.glue())
SILE.settings:set("current.parindent", SILE.types.node.glue())
SILE.settings:set("document.parindent", SILE.types.node.glue())

cancelFragile(function ()
-- Quick and dirty for now...
Expand All @@ -102,20 +104,20 @@ function package:registerCommands ()
SILE.call("medskip")
if #v.children > 0 then
SILE.call("parbox", { valign = "middle", width = "20%lw" }, function ()
SILE.settings:set("document.parindent", SILE.nodefactory.glue())
SILE.settings:set("document.parindent", SILE.types.node.glue())
SILE.call("raggedright", {}, function ()
SILE.call("fancytoc:level1", { style = "fancytoc-level1" }, v.item.label)
end)
end)
SILE.call("hfill")
SILE.call("bracebox", { bracewidth = "0.8em"}, function()
SILE.call("parbox", { valign = "middle", width = "75%lw" }, function ()
SILE.settings:set("document.parindent", SILE.nodefactory.glue())
SILE.settings:set("document.parindent", SILE.types.node.glue())
for _, c in ipairs(v.children) do
SILE.call("parbox", { valign = "top", strut = "rule", minimize = true, width = "80%lw" }, function ()
SILE.settings:set("document.lskip", SILE.length("1em"))
SILE.settings:set("document.rskip", SILE.nodefactory.hfillglue())
SILE.settings:set("document.parindent", SILE.length("-0.5em"))
SILE.settings:set("document.lskip", SILE.types.length("1em"))
SILE.settings:set("document.rskip", SILE.types.node.hfillglue())
SILE.settings:set("document.parindent", SILE.types.length("-0.5em"))
SILE.call("fancytoc:level2", { style = "fancytoc-level2" }, c.label)
end)
SILE.call("dotfill")
Expand All @@ -128,7 +130,7 @@ function package:registerCommands ()
end)
else
SILE.call("parbox", { valign = "top", width = "20%lw" }, function ()
SILE.settings:set("document.parindent", SILE.nodefactory.glue())
SILE.settings:set("document.parindent", SILE.types.node.glue())
SILE.call("raggedright", {}, function ()
SILE.call("fancytoc:level1", { style = "fancytoc-level1" }, v.item.label)
end)
Expand Down
26 changes: 26 additions & 0 deletions rockspecs/fancytoc.sile-1.1.0-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
rockspec_format = "3.0"
package = "fancytoc.sile"
version = "1.1.0-1"
source = {
url = "git+https://github.com/Omikhleia/fancytoc.sile.git",
tag = "v1.1.0",
}
description = {
summary = "Some fancy table of contents for the SILE typesetting system.",
detailed = [[
This package for the SILE typesetter provides an altenative and fancy two-level presentation
with curly braces for a table of contents.
]],
homepage = "https://github.com/Omikhleia/fancytoc.sile",
license = "MIT",
}
dependencies = {
"lua >= 5.1",
"ptable.sile >= 3.1.0",
}
build = {
type = "builtin",
modules = {
["sile.packages.fancytoc"] = "packages/fancytoc/init.lua",
}
}
File renamed without changes.