Skip to content

Commit 170450f

Browse files
authored
Merge pull request #12285 from quarto-dev/bugfix/12258
crossref - always use supplement in typst refs.
2 parents a496e0e + c401968 commit 170450f

File tree

13 files changed

+20
-35
lines changed

13 files changed

+20
-35
lines changed

src/resources/filters/crossref/refs.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function resolveRefs()
1313
local function add_ref_prefix(ref, ref_type, prefix)
1414
local category = crossref.categories.by_ref_type[ref_type]
1515
ref:extend(prefix)
16-
if category == nil or category.space_before_numbering ~= false then
16+
if (category == nil or category.space_before_numbering ~= false) and not _quarto.format.isTypstOutput() then
1717
ref:extend({nbspString()})
1818
end
1919
end
@@ -82,12 +82,13 @@ function resolveRefs()
8282
-- so we don't get the fallthrough else clause in latex when custom ref commands
8383
-- are in play
8484
if category == nil or category.custom_ref_command == nil then
85-
ref:extend({pandoc.RawInline('latex', '\\ref{' .. label .. '}')})
85+
ref:extend(pandoc.List({pandoc.RawInline('latex', '\\ref{' .. label .. '}')}))
8686
end
8787
elseif _quarto.format.isAsciiDocOutput() then
8888
ref = pandoc.List({pandoc.RawInline('asciidoc', '<<' .. label .. '>>')})
8989
elseif _quarto.format.isTypstOutput() then
90-
ref = pandoc.List({pandoc.RawInline('typst', '@' .. label)})
90+
ref:insert(1, pandoc.RawInline('typst', '#ref(<' .. label .. '>, supplement: ['))
91+
ref:insert(pandoc.RawInline('typst', '])'))
9192
else
9293
if not resolve then
9394
local refClasses = pandoc.List({"quarto-unresolved-ref"})

tests/docs/smoke-all/crossrefs/float/typst/rawtablecaption.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ _quarto:
88
ensureTypstFileRegexMatches:
99
-
1010
- "This is a caption."
11-
- "<tbl-1>"
12-
- "@tbl-1"
11+
- "#ref\\(<tbl-1>, supplement: \\[Table\\]\\)"
1312
- []
1413
---
1514

tests/docs/smoke-all/crossrefs/float/typst/typst-float-1.qmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ _quarto:
77
typst:
88
ensureTypstFileRegexMatches:
99
-
10-
- "<tbl-1>"
11-
- "<fig-1>"
12-
- "@fig-1"
13-
- "@tbl-1"
10+
- "#ref\\(<fig-1>, supplement: \\[Figure\\]\\)"
11+
- "#ref\\(<tbl-1>, supplement: \\[Table\\]\\)"
1412
- []
1513
---
1614

tests/docs/smoke-all/crossrefs/float/typst/typst-float-2.qmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ _quarto:
77
typst:
88
ensureTypstFileRegexMatches:
99
-
10-
- "<fig-foo>"
11-
- "<tbl-foo>"
12-
- "@fig-foo"
13-
- "@tbl-foo"
10+
- "#ref\\(<fig-foo>, supplement: \\[Figure\\]\\)"
11+
- "#ref\\(<tbl-foo>, supplement: \\[Table\\]\\)"
1412
- "This is the figure"
1513
- "This is the table"
1614
---

tests/docs/smoke-all/crossrefs/float/typst/typst-float-3.qmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ _quarto:
77
typst:
88
ensureTypstFileRegexMatches:
99
-
10-
- "<fig-foo>"
11-
- "<tbl-foo>"
12-
- "@fig-foo"
13-
- "@tbl-foo"
10+
- "#ref\\(<fig-foo>, supplement: \\[Figure\\]\\)"
11+
- "#ref\\(<tbl-foo>, supplement: \\[Table\\]\\)"
1412
- "This is a figure"
1513
- "This is a table"
1614
---

tests/docs/smoke-all/crossrefs/float/typst/typst-float-4.qmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ _quarto:
77
typst:
88
ensureTypstFileRegexMatches:
99
-
10-
- "<fig-foo>"
11-
- "<tbl-foo>"
12-
- "@fig-foo"
13-
- "@tbl-foo"
10+
- "#ref\\(<tbl-foo>, supplement: \\[Table\\]\\)"
11+
- "#ref\\(<fig-foo>, supplement: \\[Figure\\]\\)"
1412
- "#link\\(\"https://www.example.com/\"\\)\\[#.*image\\(\"img/surus.jpg\"\\)\\)"
1513
---
1614

tests/docs/smoke-all/crossrefs/float/typst/typst-float-6.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ _quarto:
77
typst:
88
ensureTypstFileRegexMatches:
99
-
10-
- "<fig-simple>"
11-
- "@fig-simple"
10+
- "#ref\\(<fig-simple>, supplement: \\[Figure\\]\\)"
1211
- "A simple figure"
1312
- "#.*image\\(\"img/surus.jpg\"\\)"
1413
- []

tests/docs/smoke-all/crossrefs/float/typst/typst-jupyter-1.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ _quarto:
77
typst:
88
ensureTypstFileRegexMatches:
99
-
10-
- "<fig-plot>"
11-
- "@fig-plot"
10+
- "#ref\\(<fig-plot>, supplement: \\[Figure\\]\\)"
1211
- "Plot"
1312
- "#.*image\\(\"typst-jupyter-1_files/figure-typst/fig-plot-output-1.svg\"\\)"
1413
- []

tests/docs/smoke-all/crossrefs/float/typst/typst-knitr-1.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ _quarto:
88
ensureTypstFileRegexMatches:
99
-
1010
- "Plot"
11-
- "<fig-plot>"
12-
- "@fig-plot"
11+
- "#ref\\(<fig-plot>, supplement: \\[Figure\\]\\)"
1312
---
1413

1514
## Knitr Crossref Figure

tests/docs/smoke-all/crossrefs/float/typst/typst-listings-1.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ _quarto:
77
typst:
88
ensureTypstFileRegexMatches:
99
-
10-
- "<lst-customers>"
11-
- "@lst-customers"
10+
- "#ref\\(<lst-customers>, supplement: \\[Listing\\]\\)"
1211
- "Customers Query"
1312
- []
1413
---

0 commit comments

Comments
 (0)