Skip to content

Commit

Permalink
Merge pull request #118 from Omikhleia/fix-update-sile-0.15
Browse files Browse the repository at this point in the history
refactor: Compatibility upgrade with SILE 0.15
  • Loading branch information
Omikhleia authored Aug 30, 2024
2 parents 5af2c36 + 0e55a4b commit 17e80d8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lua-libraries/lunamark/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
--- Utility functions for lunamark.

local M = {}
local cosmo = require("cosmo")
local rep = string.rep
local lpeg = require("lpeg")
local Cs, P, S, lpegmatch = lpeg.Cs, lpeg.P, lpeg.S, lpeg.match
Expand Down Expand Up @@ -49,6 +48,7 @@ end
-- it will be treated as an array with one element. If it is
-- `nil`, it will be treated as an empty array.
function M.sepby(arg)
local cosmo = require("cosmo") -- HACK OMIKHLEIA
local a = arg[1]
if not a then
a = {}
Expand Down
25 changes: 13 additions & 12 deletions packages/markdown/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--
require("silex.lang") -- Compatibility layer
require("silex.ast") -- Compatibility layer
require("silex.types") -- Compatibility layer

local utils = require("packages.markdown.utils")
local hasClass = utils.hasClass
Expand Down Expand Up @@ -708,7 +709,7 @@ Please consider using a resilient-compatible class!]])
-- NOTE: The following doesn't work: SILE.call("math", {}, content)
-- Let's go for a lower-level AST construct instead.
SILE.process({
createCommand("math", { mode = mode }, SU.contentToString(content))
createCommand("math", { mode = mode }, SU.ast.contentToString(content))
})
end)

Expand Down Expand Up @@ -783,11 +784,11 @@ Please consider using a resilient-compatible class!]])
SILE.call("smallskip")
SILE.typesetter:leaveHmode()
SILE.settings:temporarily(function ()
local indent = SILE.measurement("2em"):absolute()
local lskip = SILE.settings:get("document.lskip") or SILE.nodefactory.glue()
local rskip = SILE.settings:get("document.rskip") or SILE.nodefactory.glue()
SILE.settings:set("document.lskip", SILE.nodefactory.glue(lskip.width + indent))
SILE.settings:set("document.rskip", SILE.nodefactory.glue(rskip.width + indent))
local indent = SILE.types.measurement("2em"):absolute()
local lskip = SILE.settings:get("document.lskip") or SILE.types.node.glue()
local rskip = SILE.settings:get("document.rskip") or SILE.types.node.glue()
SILE.settings:set("document.lskip", SILE.types.node.glue(lskip.width + indent))
SILE.settings:set("document.rskip", SILE.types.node.glue(rskip.width + indent))
SILE.settings:set("font.size", SILE.settings:get("font.size") * 0.95)
SILE.process(content)
SILE.typesetter:leaveHmode()
Expand Down Expand Up @@ -835,9 +836,9 @@ Please consider using a resilient-compatible class!]])
SILE.call("strong", {}, term)
SILE.call("novbreak")
SILE.settings:temporarily(function ()
local indent = SILE.measurement("2em"):absolute()
local lskip = SILE.settings:get("document.lskip") or SILE.nodefactory.glue()
SILE.settings:set("document.lskip", SILE.nodefactory.glue(lskip.width + indent))
local indent = SILE.types.measurement("2em"):absolute()
local lskip = SILE.settings:get("document.lskip") or SILE.types.node.glue()
SILE.settings:set("document.lskip", SILE.types.node.glue(lskip.width + indent))
SILE.process(desc)
SILE.typesetter:leaveHmode()
end)
Expand All @@ -864,7 +865,7 @@ Please consider using a resilient-compatible class!]])
end, "A fallback command for Markdown to insert a captioned figure")

self:registerCommand("markdown:fallback:mark", function (_, content)
local leading = SILE.measurement("1bs"):tonumber()
local leading = SILE.types.measurement("1bs"):tonumber()
local bsratio = utils.computeBaselineRatio()
if SILE.typesetter.liner then
SILE.typesetter:liner("markdown:fallback:mark", content,
Expand All @@ -873,7 +874,7 @@ Please consider using a resilient-compatible class!]])
local H = SU.max(box.height:tonumber(), (1 - bsratio) * leading)
local D = SU.max(box.depth:tonumber(), bsratio * leading)
local X = typesetter.frame.state.cursorX
SILE.outputter:pushColor(SILE.color("yellow"))
SILE.outputter:pushColor(SILE.types.color("yellow"))
SILE.outputter:drawRule(X, typesetter.frame.state.cursorY - H, outputWidth, H + D)
SILE.outputter:popColor()
box:outputContent(typesetter, line)
Expand All @@ -895,7 +896,7 @@ Please consider using a resilient-compatible class!]])
local H = SU.max(box.height:tonumber(), (1 - bsratio) * leading)
local D = SU.max(box.depth:tonumber(), bsratio * leading)
local X = typesetter.frame.state.cursorX
SILE.outputter:pushColor(SILE.color("yellow"))
SILE.outputter:pushColor(SILE.types.color("yellow"))
SILE.outputter:drawRule(X, typesetter.frame.state.cursorY - H, outputWidth, H + D)
SILE.outputter:popColor()
hbox:outputYourself(typesetter, line)
Expand Down
61 changes: 61 additions & 0 deletions rockspecs/markdown.sile-2.1.0-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
rockspec_format = "3.0"
package = "markdown.sile"
version = "2.1.0-1"
source = {
url = "git+https://github.com/Omikhleia/markdown.sile.git",
tag = "v2.1.0",
}
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.2.0",
"labelrefs.sile >= 0.1.0",
"ptable.sile >= 3.1.0",
"smartquotes.sile >= 1.0.0",
"textsubsuper.sile >= 1.1.1",
"silex.sile >= 0.6.0, < 1.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.cmbase"] = "packages/markdown/cmbase.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",
}
}

0 comments on commit 17e80d8

Please sign in to comment.