From ab54b2d9b61d18c04c94c47fe5aaad41be48710e Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 2 Sep 2024 18:27:32 +0200 Subject: [PATCH 1/4] revealjs - keep the id when changing figure DOM for stretching feature this allows the reference link to work correctly on figures. --- src/format/reveal/format-reveal.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/format/reveal/format-reveal.ts b/src/format/reveal/format-reveal.ts index fd55a8391b5..98966183531 100644 --- a/src/format/reveal/format-reveal.ts +++ b/src/format/reveal/format-reveal.ts @@ -1002,7 +1002,7 @@ function applyStretch(doc: Document, autoStretch: boolean) { } }; - // Figure environment ? Get caption and alignment + // Figure environment ? Get caption, id and alignment const quartoFig = slideEl.querySelector("div.quarto-figure"); const caption = doc.createElement("p"); if (quartoFig) { @@ -1011,6 +1011,9 @@ function applyStretch(doc: Document, autoStretch: boolean) { "quarto-figure-(center|left|right)", ); if (align) imageEl.classList.add(align[0]); + // Get id + const quartoFigId = quartoFig?.id; + if (quartoFigId) imageEl.id = quartoFigId; // Get Caption const figCaption = nodeEl.querySelector("figcaption"); if (figCaption) { From f8e3406327d71b6f07454f7cd90090967ce1bb72 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 2 Sep 2024 18:28:53 +0200 Subject: [PATCH 2/4] revealjs 5 - Links to element in slide by id work in latest reveal.js So no need to tweak a reference by slide. Added feature : https://github.com/hakimel/reveal.js/pull/3444 --- src/format/reveal/format-reveal.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/format/reveal/format-reveal.ts b/src/format/reveal/format-reveal.ts index 98966183531..3633603df17 100644 --- a/src/format/reveal/format-reveal.ts +++ b/src/format/reveal/format-reveal.ts @@ -783,23 +783,6 @@ const handleAnchors = (doc: Document) => { const codeLineAnchorEl = codeLineAnchor as Element; codeLineAnchorEl.removeAttribute("href"); }); - - // https://github.com/quarto-dev/quarto-cli/issues/3533 - // redirect anchors to the slide they refer to - const anchors = doc.querySelectorAll("a[href^='#/']"); - for (const anchor of anchors) { - const anchorEl = anchor as Element; - const href = anchorEl.getAttribute("href"); - if (href) { - const target = doc.getElementById(href.replace(/^#\//, "")); - if (target) { - const slide = findParentSlide(target); - if (slide && slide.getAttribute("id")) { - anchorEl.setAttribute("href", `#/${slide.getAttribute("id")}`); - } - } - } - } }; const handleInterColumnDivSpaces = (doc: Document) => { From 2140278ee8f737c1e4107f94edaa253c1440ca3b Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 2 Sep 2024 18:38:02 +0200 Subject: [PATCH 3/4] revealjs - add tests to links to elements including #3533 solved by #4623 without a test at the time --- tests/docs/smoke-all/2024/09/02/10657.qmd | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/docs/smoke-all/2024/09/02/10657.qmd diff --git a/tests/docs/smoke-all/2024/09/02/10657.qmd b/tests/docs/smoke-all/2024/09/02/10657.qmd new file mode 100644 index 00000000000..965d6460403 --- /dev/null +++ b/tests/docs/smoke-all/2024/09/02/10657.qmd @@ -0,0 +1,58 @@ +--- +title: Links to nested elements works +format: revealjs +_quarto: + tests: + revealjs: + ensureHtmlElements: + - + - 'img.r-stretch#fig-elephant' + - 'a[href="#/fig-elephant"]' + - 'img.r-stretch#elephant' + - 'a[href="#/elephant"]' + - 'span#eq-EEE > span.math' + - 'a[href="#/eq-EEE"]' + - 'div.theorem#thm-TTT' + - 'a[href="#/thm-TTT"]' + - [] +--- + + + +## Quarto Figure + +![Elephant](https://quarto.org/docs/authoring/images/crossref-figure.png){#fig-elephant} + +## Link to the figure + +See [Figure Element](#fig-elephant) + +## Image + +![Elephant](https://quarto.org/docs/authoring/images/crossref-figure.png){#elephant} + +## Link to the image + +See [Figure Element](#elephant) + +## Equation + +$$ +\begin{aligned} + f(X) = y. +\end{aligned} +$$ {#eq-EEE} + +## Link to equation + +See @eq-EEE. + +## Theorem + +::: {#thm-TTT} +Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat. +::: + +## Link to theorem + +See @thm-TTT. \ No newline at end of file From 2600d5512d6dd530dedab7d539a98999b72a1b92 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 2 Sep 2024 18:41:23 +0200 Subject: [PATCH 4/4] Add to changelog --- news/changelog-1.6.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/news/changelog-1.6.md b/news/changelog-1.6.md index 048ff18b6c9..3ed40d1e6c8 100644 --- a/news/changelog-1.6.md +++ b/news/changelog-1.6.md @@ -14,8 +14,9 @@ All changes included in 1.6: ## `revealjs` Format -- Update to Reveal JS 5.1.0. +- Update to Reveal JS 5.1.0 - ([#7715](https://github.com/quarto-dev/quarto-cli/issues/7715)): Revealjs don't support anymore special Pandoc syntax making BulletList in Blockquotes become incremental list. This was confusing and unexpected behavior. Supported syntax for incremental list is documented at . +- ([#9742](https://github.com/quarto-dev/quarto-cli/issues/9742)): Links to cross-referenced images correctly works. ## `typst` Format