diff --git a/src/resources/filters/main.lua b/src/resources/filters/main.lua index a265f14ba30..347733fc3b5 100644 --- a/src/resources/filters/main.lua +++ b/src/resources/filters/main.lua @@ -296,6 +296,12 @@ local quarto_pre_filters = { traverser = 'jog', }, + { name = "strip-notes-from-hidden", + filter = strip_notes_from_hidden(), + flags = { "has_notes" }, + traverser = 'jog', + }, + { name = "pre-combined-hidden", filter = combineFilters({ hidden(), diff --git a/src/resources/filters/normalize/flags.lua b/src/resources/filters/normalize/flags.lua index beb2dab47b9..07fc80ea68b 100644 --- a/src/resources/filters/normalize/flags.lua +++ b/src/resources/filters/normalize/flags.lua @@ -178,7 +178,10 @@ function compute_flags() end, Figure = function(node) flags.has_pandoc3_figure = true - end + end, + Note = function(node) + flags.has_notes = true + end, }, { Meta = function(el) local lightbox_auto = lightbox_module.automatic(el) diff --git a/src/resources/filters/normalize/normalize.lua b/src/resources/filters/normalize/normalize.lua index 2937e4d0bef..121b571ddc7 100644 --- a/src/resources/filters/normalize/normalize.lua +++ b/src/resources/filters/normalize/normalize.lua @@ -20,15 +20,6 @@ local authors = require 'modules/authors' local license = require 'modules/license' local shortcode_ast = require 'modules/astshortcode' -local function stripNotes(el) - local result = _quarto.ast.walk(el, { - Note = function(_el) - return pandoc.Null() - end - }) - return result -end - function normalize_filter() return { Meta = function(meta) @@ -59,22 +50,6 @@ function normalize_filter() normalized = shortcode_ast.parse(normalized) return normalized - end, - Div = function(div) - -- Don't allow footnotes in the hidden element (markdown pipeline) - -- since that will result in duplicate footnotes - -- in the rendered output - if div.classes:includes('hidden') then - return stripNotes(div) - end - end, - Span = function(span) - -- Don't allow footnotes in the hidden element (markdown pipeline) - -- since that will result in duplicate footnotes - -- in the rendered output - if span.classes:includes('hidden') then - return stripNotes(span) - end end } end diff --git a/src/resources/filters/quarto-pre/hidden.lua b/src/resources/filters/quarto-pre/hidden.lua index 813fb531652..6f13ce7d2d5 100644 --- a/src/resources/filters/quarto-pre/hidden.lua +++ b/src/resources/filters/quarto-pre/hidden.lua @@ -81,8 +81,32 @@ function hidden() end end - - - - - +function strip_notes_from_hidden() + local function stripNotes(el) + local result = _quarto.ast.walk(el, { + Note = function(_el) + return pandoc.Null() + end + }) + return result + end + + return { + Div = function(div) + -- Don't allow footnotes in the hidden element (markdown pipeline) + -- since that will result in duplicate footnotes + -- in the rendered output + if div.classes:includes('hidden') then + return stripNotes(div) + end + end, + Span = function(span) + -- Don't allow footnotes in the hidden element (markdown pipeline) + -- since that will result in duplicate footnotes + -- in the rendered output + if span.classes:includes('hidden') then + return stripNotes(span) + end + end + } +end \ No newline at end of file