Skip to content

Commit

Permalink
Merge pull request #128 from Omikhleia/fix-embedders-detection
Browse files Browse the repository at this point in the history
fix: Broken embedders detection for rendered code blocks
  • Loading branch information
Omikhleia authored Nov 26, 2024
2 parents b0d9ced + 414ed06 commit 2b977f9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/markdown/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ local function hasRawHandler (options)
end

--- Find the first embedder suitable for the given pseudo-class attributes.
---@param options table Command options
---@param options table Command options with class attribute (nil or list of comma-separated classes)
---@return string|nil, function Embedder name and handler function (if found)
local function hasEmbedHandler (options)
if not options.class then
return nil
end
local handler = SILE.rawHandlers["embed"]
if not handler then
-- Shouldn't occur since we loaded the embedders package
Expand All @@ -73,12 +76,17 @@ local function hasEmbedHandler (options)
if not embedders then
return nil
end
for name, _ in pairs(SILE.scratch.embedders) do
if hasClass(options, name) then
local classes = pl.stringx.split(options.class, " ")
for _, name in ipairs(classes) do
SU.debug("markdown", "Checking for embedder", name)
if embedders[name] then
-- NOTE: Accessing the embedder table causes the entry to be loaded
-- if it exists and is not loaded yet.
SU.debug("markdown", "Found an embedder for", name)
return name, handler
end
end
SU.debug("markdown", "No embedder found")
return nil
end

Expand Down

0 comments on commit 2b977f9

Please sign in to comment.