Skip to content

crossref - add support for algorithm (alg-) theorem #12615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions news/changelog-1.8.md
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 7 additions & 2 deletions src/resources/filters/customnodes/theorem.lua
Original file line number Diff line number Diff line change
@@ -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)
47 changes: 47 additions & 0 deletions tests/docs/smoke-all/crossrefs/theorem/algorithm.qmd
Original file line number Diff line number Diff line change
@@ -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\\(<alg-gcd>, supplement: \\[alg.\\]\\)"
- "#ref\\(<alg-gcd>, 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.