Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure with empty caption and cross-ref label rendered to HTML crashes main.lua #10281

Closed
jbrick55 opened this issue Jul 12, 2024 · 6 comments
Closed
Assignees
Labels
backport bug Something isn't working lightbox regression Functionality that used to work but now is broken.
Milestone

Comments

@jbrick55
Copy link

Bug description

There appears to be something in Lua filter causing errors when I do not have a caption for a figure but I do have it labeled for cross-reference. I believe this is related to #9675

Steps to reproduce

The following code is for a graph (this also happens with images with no captions) with no fig-cap but has a label. This will produce a Lua error (as shown below).
If I remove the label inside the r code and use :::{#fig-Rgraph} before the code and remove the #|label from the code chunk it will render properly. All of my previously working graphs and images now throw this error when trying to render.

---
title: "Reproducible Quarto Document"
format: html
engine: knitr
---

```{r message=FALSE, warning=FALSE, error=FALSE, out.width="70%"}
#| label: fig-Rgraph
#| fig-alt: "Simple plot"
#| eval: true
#| echo: false
#| lightbox: true

x <- 1:10
y <- x^2

plot(x, y, 
     type = "o",        
     col = "blue",      
     pch = 16,         
     lty = 2,           
     main = "Simple Plot",   
     xlab = "X axis",  
     ylab = "Y axis"    
     )
```

Expected behavior

The code should render to html as a graph.

Actual behavior

Lua Error:

Error running filter /Applications/quarto/share/filters/main.lua:
/Applications/quarto/share/filters/main.lua:11765: attempt to index a nil value (field 'caption_long')
stack traceback:
	[C]: in ?
	[C]: in method 'walk'
	/Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
	(...tail calls...)
	/Applications/quarto/share/filters/main.lua:11762: in local 'filter_fn'
	/Applications/quarto/share/filters/main.lua:635: in function </Applications/quarto/share/filters/main.lua:625>
	(...tail calls...)
	[C]: in ?
	[C]: in method 'walk'
	/Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
	(...tail calls...)
	/Applications/quarto/share/filters/main.lua:1334: in local 'callback'
	/Applications/quarto/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
	/Applications/quarto/share/filters/main.lua:1388: in function </Applications/quarto/share/filters/main.lua:1385>
stack traceback:
	/Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
	(...tail calls...)
	/Applications/quarto/share/filters/main.lua:11762: in local 'filter_fn'
	/Applications/quarto/share/filters/main.lua:635: in function </Applications/quarto/share/filters/main.lua:625>
	(...tail calls...)
	[C]: in ?
	[C]: in method 'walk'
	/Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
	(...tail calls...)
	/Applications/quarto/share/filters/main.lua:1334: in local 'callback'
	/Applications/quarto/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
	/Applications/quarto/share/filters/main.lua:1388: in function </Applications/quarto/share/filters/main.lua:1385>
stack traceback:
	/Applications/quarto/share/filters/main.lua:557: in function </Applications/quarto/share/filters/main.lua:546>
	(...tail calls...)
	/Applications/quarto/share/filters/main.lua:1334: in local 'callback'
	/Applications/quarto/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
	/Applications/quarto/share/filters/main.lua:1388: in function </Applications/quarto/share/filters/main.lua:1385>

Your environment

  • IDE: RStudio Version 2024.04.2+764 (2024.04.2+764)
  • MacOS: 14.5 (23F79)

Quarto check output

Quarto 1.5.53
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.5.53
Path: /Applications/quarto/bin

[✓] Checking tools....................OK
TinyTeX: (external install)
Chromium: (not installed)

[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/jmh491/Library/TinyTeX/bin/universal-darwin
Version: 2023

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
Version: 3.12.3
Path: /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
Jupyter: 5.7.2
Kernels: sas, python3

(/) Checking Jupyter engine render....Traceback (most recent call last):
File "/Applications/quarto/share/jupyter/jupyter.py", line 21, in
from notebook import notebook_execute, RestartKernel
File "/Applications/quarto/share/jupyter/notebook.py", line 15, in
from yaml import safe_load as parse_string
ModuleNotFoundError: No module named 'yaml'
[✓] Checking Jupyter engine render....OK

@jbrick55 jbrick55 added the bug Something isn't working label Jul 12, 2024
@cderv
Copy link
Collaborator

cderv commented Jul 15, 2024

I can reproduce using 1.5.54 but it does not happen with 1.6.1 nor 1.4.555.

Thanks for the report !

@cderv cderv added the regression Functionality that used to work but now is broken. label Jul 15, 2024
@cderv cderv added this to the Hot-fix milestone Jul 15, 2024
@cderv
Copy link
Collaborator

cderv commented Jul 15, 2024

This is an issue with lightbox: true when no caption is set.

---
title: "Reproducible Quarto Document"
format: html
engine: knitr
keep-md: true
---

```{r}
#| label: fig-Rgraph
#| lightbox: true
x <- 1:10
y <- x^2
plot(x, y)
```

@cderv
Copy link
Collaborator

cderv commented Jul 15, 2024

This is related to

fixed in

So using latest pre-release will have the fix

@cscheid did you plan to backport ? Or is there a reason not to ? I see the hot-fix milestone in #10196 so I would have expected #10198 to have been backported to 1.5 branch too for next patch release

Thanks

@cderv cderv added triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. lightbox pandoc and removed pandoc labels Jul 15, 2024
@cscheid
Copy link
Collaborator

cscheid commented Jul 16, 2024

@cderv Thanks, I missed this. I've now backported to v1.5. It'll be out on our next stable release.

@cscheid cscheid closed this as completed Jul 16, 2024
@cderv
Copy link
Collaborator

cderv commented Jul 17, 2024

Perfect - thanks ! I would have done it, but I prefered checking with you first.

For any future readers, this will be fixed in v1.5.55.

@cderv cderv added backport and removed triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. labels Jul 17, 2024
@jbrick55
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport bug Something isn't working lightbox regression Functionality that used to work but now is broken.
Projects
None yet
Development

No branches or pull requests

3 participants