From 9e4d200fcf9e39aa7acb79f697de1f8bbe7e09d1 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 16 Nov 2023 13:31:23 -0700 Subject: [PATCH] be more robust when searching for longtable rawblocks --- .../filters/customnodes/floatreftarget.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/resources/filters/customnodes/floatreftarget.lua b/src/resources/filters/customnodes/floatreftarget.lua index 3488b318c7f..ceb6d1ed3fd 100644 --- a/src/resources/filters/customnodes/floatreftarget.lua +++ b/src/resources/filters/customnodes/floatreftarget.lua @@ -273,9 +273,16 @@ end, function(float) }) -- special case for singleton longtable floats - if float_type == "tbl" then - local raw = quarto.utils.match("Div/.cell-output-display/[1]/RawBlock")(float.content) - if raw and _quarto.format.isRawLatex(raw) and raw.text:match(_quarto.patterns.latexLongtablePattern) then + if float_type == "tbl" then + local raw + _quarto.ast.walk(float.content, { + RawBlock = function(el) + if _quarto.format.isRawLatex(el) and el.text:match(_quarto.patterns.latexLongtablePattern) then + raw = el + end + end + }) + if raw then local longtable_content = raw.text:gsub(_quarto.patterns.latexLongtablePattern, "%2", 1) -- split the content into params and actual content -- params are everything in the first line of longtable_content