Skip to content

Commit ab54b2d

Browse files
committed
revealjs - keep the id when changing figure DOM for stretching feature
this allows the reference link to work correctly on figures.
1 parent 1ce279b commit ab54b2d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/format/reveal/format-reveal.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ function applyStretch(doc: Document, autoStretch: boolean) {
10021002
}
10031003
};
10041004

1005-
// Figure environment ? Get caption and alignment
1005+
// Figure environment ? Get caption, id and alignment
10061006
const quartoFig = slideEl.querySelector("div.quarto-figure");
10071007
const caption = doc.createElement("p");
10081008
if (quartoFig) {
@@ -1011,6 +1011,9 @@ function applyStretch(doc: Document, autoStretch: boolean) {
10111011
"quarto-figure-(center|left|right)",
10121012
);
10131013
if (align) imageEl.classList.add(align[0]);
1014+
// Get id
1015+
const quartoFigId = quartoFig?.id;
1016+
if (quartoFigId) imageEl.id = quartoFigId;
10141017
// Get Caption
10151018
const figCaption = nodeEl.querySelector("figcaption");
10161019
if (figCaption) {

0 commit comments

Comments
 (0)