Skip to content

Commit f4b887b

Browse files
authored
Merge pull request #10360 from quarto-dev/bugfix/10358
floats - ensure caption_long exists and has content
2 parents 2338e35 + cd6fbec commit f4b887b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/resources/filters/customnodes/floatreftarget.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,15 @@ function decorate_caption_with_crossref(float)
202202
internal_error()
203203
-- luacov: enable
204204
end
205-
local caption_content = (float.caption_long and float.caption_long.content) or float.caption_long or pandoc.Inlines({})
205+
if float.caption_long and float.caption_long.content == nil then
206+
local error_msg = "FloatRefTarget has caption_long field of type " .. tostring(float.caption_long.t) .. " which doesn't support content: " .. float.identifier
207+
error(error_msg)
208+
return {}
209+
end
210+
if float.caption_long == nil then
211+
float.caption_long = pandoc.Plain({})
212+
end
213+
local caption_content = float.caption_long.content
206214

207215
if float.parent_id then
208216
if float.order == nil then
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: "Minimal example"
3+
format: gfm
4+
keep-md: true
5+
---
6+
7+
8+
::: {.cell execution_count=1}
9+
``` {.python .cell-code}
10+
import matplotlib.pyplot as plt
11+
import numpy as np
12+
13+
x = np.linspace(0,1,10)
14+
y = np.sin(x)
15+
16+
plt.plot(x,y)
17+
```
18+
19+
::: {.cell-output .cell-output-display}
20+
![](10358_files/figure-commonmark/fig-sin-output-1.png){#fig-sin}
21+
:::
22+
:::
23+
24+

0 commit comments

Comments
 (0)