-
Notifications
You must be signed in to change notification settings - Fork 417
Closed
Labels
bugSomething isn't workingSomething isn't workingluaIssues related to the lua codebase, filter chain, etcIssues related to the lua codebase, filter chain, etcregressionFunctionality that used to work but now is broken.Functionality that used to work but now is broken.
Milestone
Description
This was found in the context of #7493
From rstudio/gt#146 I understand that using HTML in a table colums to show as HTML in gt table, it requires to use fmt_markdown
---
title: "Test"
format: html
keep-md: true
---
```{r}
library(gt)
data.frame(A = "Text", B = "**Text**") |>
gt() |>
fmt_markdown(B)
```With 1.4 we get a Lua error
Error running filter C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/resources/filters/main.lua:
...2/src/resources/filters/./quarto-pre/parsefiguredivs.lua:425: attempt to index a nil value (field 'classes')
Stacktrace
Error running filter C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/resources/filters/main.lua:
...2/src/resources/filters/./quarto-pre/parsefiguredivs.lua:425: attempt to index a nil value (field 'classes')
stack traceback:
...DEV_R/QUARTO~2/src/resources/filters/./common/pandoc.lua:52: in function <...DEV_R/QUARTO~2/src/resources/filters/./common/pandoc.lua:46>
(...tail calls...)
[C]: in ?
[C]: in method 'walk'
...V_R/QUARTO~2/src/resources/filters/./ast/customnodes.lua:86: in function <...V_R/QUARTO~2/src/resources/filters/./ast/customnodes.lua:76>
(...tail calls...)
..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:40: in local 'callback'
..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:54: in upvalue 'run_emulated_filter_chain'
..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:89: in function <..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:86>
stack traceback:
...V_R/QUARTO~2/src/resources/filters/./ast/customnodes.lua:86: in function <...V_R/QUARTO~2/src/resources/filters/./ast/customnodes.lua:76>
(...tail calls...)
..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:40: in local 'callback'
..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:54: in upvalue 'run_emulated_filter_chain'
..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:89: in function <..._R/QUARTO~2/src/resources/filters/./ast/runemulation.lua:86>
ERROR: Error
at renderFiles (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/render/render-files.ts:343:23)
at eventLoopTick (ext:core/01_core.js:181:11)
at async renderProject (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/render/project.ts:268:23)
at async renderForPreview (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/preview/preview.ts:426:24)
at async render (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/preview/preview.ts:162:22)
at async preview (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/preview/preview.ts:179:18)
at async Command.fn (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/command/preview/cmd.ts:401:7)
at async Command.execute (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/vendor/deno.land/x/cliffy@v0.25.4/command/command.ts:1790:7)
at async quarto (file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/quarto.ts:155:3)
at async file:///C:/Users/chris/DOCUME~1/DEV_R/QUARTO~2/src/quarto.ts:186:5Error is from
| process_div_caption_classes(div) |
The HTML table we get is this one
<table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="A">A</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="B">B</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr><td headers="A" class="gt_row gt_left">Text</td>
<td headers="B" class="gt_row gt_left"><div data-qmd="**Text**"><div class='gt_from_md'><p><strong>Text</strong></p>
</div></div></td></tr>
</tbody>
</table>The div data-qmd has indeed no class.
I would say
-
either we always need to test for existence before using includes
if div.classes and div.classes:include("cell")
which solve the issue here.
if we do this fix, it seems there is a bunch of places where we need to do that, looking at our usage of
:includes() -
either this is a broader issue where the HTML table parsing is not correctly setting an empty classes attributes. Which
pandoc.Div()seems to do by default$ pandoc lua -i Lua 5.4.4 Copyright (C) 1994-2022 Lua.org, PUC-Rio Embedded in pandoc 3.1.9 > div = pandoc.Div({}) > div.classes List {} > div.classes:includes("dummy") false
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingluaIssues related to the lua codebase, filter chain, etcIssues related to the lua codebase, filter chain, etcregressionFunctionality that used to work but now is broken.Functionality that used to work but now is broken.