Skip to content

Commit a396be4

Browse files
authored
Merge pull request #12615 from quarto-dev/feature/alg-theorem
crossref - add support for algorithm (alg-) theorem
2 parents ba2634a + 0466936 commit a396be4

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

news/changelog-1.8.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ All changes included in 1.8:
1212

1313
- ([#12551](https://github.com/quarto-dev/quarto-cli/pull/12551)): Improve warning issued when `aliases` would overwrite an existing document.
1414
- ([#12616](https://github.com/quarto-dev/quarto-cli/issues/12616)): find SVG images in image discovery for listings.
15+
16+
## Crossrefs
17+
18+
- ([#12615](https://github.com/quarto-dev/quarto-cli/pull/12615)): Adds `algorithm` to theorem environments. (author: @jeremy9959)

src/resources/filters/customnodes/theorem.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ theorem_types = {
4040
style = "definition",
4141
title = "Example",
4242
},
43-
exr = {
43+
exr = {
4444
env = "exercise",
4545
style = "definition",
4646
title = "Exercise"
47-
}
47+
},
48+
alg = {
49+
env = "algorithm",
50+
style = "plain",
51+
title = "Algorithm"
52+
},
4853
}
4954

5055
function has_theorem_ref(el)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
format:
3+
typst:
4+
keep-typ: true
5+
_quarto:
6+
tests:
7+
html:
8+
ensureHtmlElements:
9+
-
10+
- "a.quarto-xref"
11+
- []
12+
latex:
13+
ensureFileRegexMatches:
14+
-
15+
- "hypertarget{alg-gcd}"
16+
- "label{alg-gcd}"
17+
- "Alg.~\\\\ref\\{alg-gcd\\}"
18+
- "alg.~\\\\ref\\{alg-gcd\\}"
19+
- []
20+
typst:
21+
ensureTypstFileRegexMatches:
22+
-
23+
- "#ref\\(<alg-gcd>, supplement: \\[alg.\\]\\)"
24+
- "#ref\\(<alg-gcd>, supplement: \\[Alg.\\]\\)"
25+
- "#algorithm\\(\"Euclid\"\\)"
26+
- []
27+
markdown:
28+
ensureFileRegexMatches:
29+
-
30+
- "\\[alg. 1\\]\\(#alg-gcd\\)\\{.quarto-xref\\}" # note the non-breaking space in "alg. 1"
31+
- '\[\*\*Algorithm 1 \(Euclid\)\*\*\]\{.theorem-title\}'
32+
---
33+
34+
::: {#alg-gcd}
35+
36+
## Euclid
37+
38+
```
39+
gcd(a, b) =
40+
if b == 0 then return a
41+
return gcd(b, a mod b)
42+
```
43+
44+
:::
45+
46+
47+
See @alg-gcd. @Alg-gcd has been known since the antiquity.

0 commit comments

Comments
 (0)