From a29217c296a281625512d5fac100a85ce6ebfdf4 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 24 Apr 2025 12:14:10 -0400 Subject: [PATCH 1/2] crossref - add support for algorithm (alg-) theorem, thanks @jeremy9959 --- src/resources/filters/customnodes/theorem.lua | 9 +++- .../smoke-all/crossrefs/theorem/algorithm.qmd | 47 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/docs/smoke-all/crossrefs/theorem/algorithm.qmd diff --git a/src/resources/filters/customnodes/theorem.lua b/src/resources/filters/customnodes/theorem.lua index a18cf74dccb..e05eca41024 100644 --- a/src/resources/filters/customnodes/theorem.lua +++ b/src/resources/filters/customnodes/theorem.lua @@ -40,11 +40,16 @@ theorem_types = { style = "definition", title = "Example", }, - exr = { + exr = { env = "exercise", style = "definition", title = "Exercise" - } + }, + alg = { + env = "algorithm", + style = "plain", + title = "Algorithm" + }, } function has_theorem_ref(el) diff --git a/tests/docs/smoke-all/crossrefs/theorem/algorithm.qmd b/tests/docs/smoke-all/crossrefs/theorem/algorithm.qmd new file mode 100644 index 00000000000..3df6e707adf --- /dev/null +++ b/tests/docs/smoke-all/crossrefs/theorem/algorithm.qmd @@ -0,0 +1,47 @@ +--- +format: + typst: + keep-typ: true +_quarto: + tests: + html: + ensureHtmlElements: + - + - "a.quarto-xref" + - [] + latex: + ensureFileRegexMatches: + - + - "hypertarget{alg-gcd}" + - "label{alg-gcd}" + - "Alg.~\\\\ref\\{alg-gcd\\}" + - "alg.~\\\\ref\\{alg-gcd\\}" + - [] + typst: + ensureTypstFileRegexMatches: + - + - "#ref\\(, supplement: \\[alg.\\]\\)" + - "#ref\\(, supplement: \\[Alg.\\]\\)" + - "#algorithm\\(\"Euclid\"\\)" + - [] + markdown: + ensureFileRegexMatches: + - + - "\\[alg. 1\\]\\(#alg-gcd\\)\\{.quarto-xref\\}" # note the non-breaking space in "alg. 1" + - '\[\*\*Algorithm 1 \(Euclid\)\*\*\]\{.theorem-title\}' +--- + +::: {#alg-gcd} + +## Euclid + +``` +gcd(a, b) = + if b == 0 then return a + return gcd(b, a mod b) +``` + +::: + + +See @alg-gcd. @Alg-gcd has been known since the antiquity. \ No newline at end of file From 0466936f54af984e9f79db9f3fe31bcbd6fad745 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Tue, 29 Apr 2025 11:22:20 -0400 Subject: [PATCH 2/2] changelog --- news/changelog-1.8.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/news/changelog-1.8.md b/news/changelog-1.8.md index 48b33d42c84..7e58237e6bc 100644 --- a/news/changelog-1.8.md +++ b/news/changelog-1.8.md @@ -12,3 +12,7 @@ All changes included in 1.8: - ([#12551](https://github.com/quarto-dev/quarto-cli/pull/12551)): Improve warning issued when `aliases` would overwrite an existing document. - ([#12616](https://github.com/quarto-dev/quarto-cli/issues/12616)): find SVG images in image discovery for listings. + +## Crossrefs + +- ([#12615](https://github.com/quarto-dev/quarto-cli/pull/12615)): Adds `algorithm` to theorem environments. (author: @jeremy9959)