Skip to content

Commit

Permalink
Merge pull request #5105 from quarto-dev/bugfix/5103
Browse files Browse the repository at this point in the history
Docusarus: recurse into custom writers
  • Loading branch information
dragonstyle authored Apr 6, 2023
2 parents 6d3aa57 + 35fd0b3 commit 37ce045
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/resources/extensions/quarto/docusaurus/docusaurus_writer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local function jsx(content)
return pandoc.RawBlock("markdown", content)
end

local function tabset(node)
local function tabset(node, filter)
-- note groupId
local groupId = ""
local group = node.attr.attributes["group"]
Expand All @@ -30,7 +30,7 @@ local function tabset(node)
local title = node.tabs[i].title

tabs.content:insert(jsx(([[<TabItem value="%s">]]):format(pandoc.utils.stringify(title))))
tabs.content:extend(content)
tabs.content:extend(quarto._quarto.ast.walk(content, filter))
tabs.content:insert(jsx("</TabItem>"))
end

Expand All @@ -45,8 +45,8 @@ local function tabset(node)
end

function Writer(doc, opts)

doc = quarto._quarto.ast.walk(doc, {
local filter
filter = {
DecoratedCodeBlock = function(node)
local el = node.code_block
local lang = el.attr.classes[1]
Expand All @@ -65,19 +65,23 @@ function Writer(doc, opts)
return nil
end,

Tabset = tabset,
Tabset = function(node)
return tabset(node, filter)
end,

Callout = function(node)
local admonition = pandoc.List()
admonition:insert(pandoc.RawBlock("markdown", "\n:::" .. node.type))
if node.title then
admonition:insert(pandoc.Header(2, node.title))
end
admonition:extend(node.content)
admonition:extend(quarto._quarto.ast.walk(node.content, filter))
admonition:insert(pandoc.RawBlock("markdown", ":::\n"))
return admonition
end
})
}

doc = quarto._quarto.ast.walk(doc, filter)

-- insert exports at the top if we have them
if #rawHtmlVars > 0 then
Expand Down

0 comments on commit 37ce045

Please sign in to comment.