Skip to content

Commit

Permalink
Merge 7ae72a1 into 1e5773c
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Dec 6, 2023
2 parents 1e5773c + 7ae72a1 commit 825e87f
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions classes/base.lua
Expand Up @@ -334,10 +334,35 @@ function class:registerCommands ()

self:registerCommand("script", function (options, content)
local packopts = packOptions(options)
local function _deprecated (original, suggested)
SU.deprecated("\\script", "\\use or \\lua", "0.15.0", "0.16.0", ([[
Use of the \\script function is deprecated. It was overloaded to mean too
many different things at once and more targeted tools were introduced in
SILE v0.14.0. To load 3rd party modules designed for use with SILE, use
\use[module=...] instead of \script[src=...]. To run arbitrary Lua code
use \lua{}, optionally with a require= parameter to load a (non-SILE) Lua
module using the Lua module path or src= to load a file by file path.
For this use case consider replacing:
%s
with:
%s
]]):format(original, suggested))
end
if SU.hasContent(content) then
return SILE.processString(content[1], options.format or "lua", nil, packopts)
local result = SILE.processString(content[1], options.format or "lua", nil, packopts)
_deprecated("\\script{...}", "\\lua{...}")
return result
elseif options.src then
return SILE.require(options.src)
local module = options.src:gsub("%/", ".")
local original = (("\\script[src=%s]"):format(options.src))
local result = SILE.require(options.src)
local suggested = (result._name and "\\use[module=%s]" or "\\lua[require=%s]"):format(module)
_deprecated(original, suggested)
return result
else
SU.error("\\script function requires inline content or a src file path")
return SILE.processString(content[1], options.format or "lua", nil, packopts)
Expand Down

0 comments on commit 825e87f

Please sign in to comment.