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) 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