From 35fd0b30b90b6c0327c11a91120934a353a5e27f Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Wed, 5 Apr 2023 10:27:38 -0700 Subject: [PATCH] recurse into custom writers --- .../quarto/docusaurus/docusaurus_writer.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/resources/extensions/quarto/docusaurus/docusaurus_writer.lua b/src/resources/extensions/quarto/docusaurus/docusaurus_writer.lua index 5e543d3d24..1e96dd296e 100644 --- a/src/resources/extensions/quarto/docusaurus/docusaurus_writer.lua +++ b/src/resources/extensions/quarto/docusaurus/docusaurus_writer.lua @@ -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"] @@ -30,7 +30,7 @@ local function tabset(node) local title = node.tabs[i].title tabs.content:insert(jsx(([[]]):format(pandoc.utils.stringify(title)))) - tabs.content:extend(content) + tabs.content:extend(quarto._quarto.ast.walk(content, filter)) tabs.content:insert(jsx("")) end @@ -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] @@ -65,7 +65,9 @@ function Writer(doc, opts) return nil end, - Tabset = tabset, + Tabset = function(node) + return tabset(node, filter) + end, Callout = function(node) local admonition = pandoc.List() @@ -73,11 +75,13 @@ function Writer(doc, opts) 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