Skip to content

Commit 733f8b7

Browse files
committed
fix: nicer structure and warning is only emitted when necessary
1 parent 2542e4d commit 733f8b7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/core/jupyter/jupyter.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,20 +1555,22 @@ async function mdFromCodeCell(
15551555

15561556
for (const { index, output } of sortedOutputs) {
15571557
// compute output label
1558-
const outputLabel = label &&
1558+
let outputLabel_tmp = label;
1559+
if (label &&
15591560
(
15601561
labelCellContainer ||
15611562
(Array.isArray(sortedOutputs) && (sortedOutputs.length > 1))
15621563
) &&
1563-
isDisplayData(output)
1564-
? (label + "-" + nextOutputSuffix++)
1565-
: label;
1566-
// If the user specifies a top-level array for images but also labels give a warning.
1567-
if (labelCellContainer === false &&
1568-
(Array.isArray(sortedOutputs) == true && (sortedOutputs.length > 1))
1569-
) {
1570-
warning("Warning: using multiple top-level figures with labels might result in unwanted behaviour.")
1564+
isDisplayData(output)) {
1565+
outputLabel_tmp = label + "-" + nextOutputSuffix++;
1566+
// If the user specifies a top-level array for images but also labels give a warning.
1567+
if (labelCellContainer === false &&
1568+
(Array.isArray(sortedOutputs) == true && (sortedOutputs.length > 1))
1569+
) {
1570+
warning("Warning: using multiple top-level figures with labels might result in unwanted behaviour: " + label)
1571+
}
15711572
}
1573+
const outputLabel = outputLabel_tmp
15721574
// If this output has been marked to not be displayed
15731575
// just continue
15741576
if (output.metadata?.[kQuartoOutputDisplay] === false) {

0 commit comments

Comments
 (0)