diff --git a/lua-libraries/lunamark/util.lua b/lua-libraries/lunamark/util.lua index 2c22df9..44fe843 100644 --- a/lua-libraries/lunamark/util.lua +++ b/lua-libraries/lunamark/util.lua @@ -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 @@ -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 = {} diff --git a/packages/markdown/commands.lua b/packages/markdown/commands.lua index a2d8542..53350d2 100644 --- a/packages/markdown/commands.lua +++ b/packages/markdown/commands.lua @@ -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 @@ -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) @@ -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() @@ -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) @@ -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, @@ -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) @@ -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) diff --git a/rockspecs/markdown.sile-2.1.0-1.rockspec b/rockspecs/markdown.sile-2.1.0-1.rockspec new file mode 100644 index 0000000..1f562a0 --- /dev/null +++ b/rockspecs/markdown.sile-2.1.0-1.rockspec @@ -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", + } +}