From ed1dea4c102761ac0cfd30b52ad46ff128d7b8c9 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 13 Mar 2025 14:34:27 -0400 Subject: [PATCH 1/4] crossref - always use supplement in typst refs. Closes #12258 --- src/resources/filters/crossref/refs.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/resources/filters/crossref/refs.lua b/src/resources/filters/crossref/refs.lua index b5150fe1a65..39a82a22a7a 100644 --- a/src/resources/filters/crossref/refs.lua +++ b/src/resources/filters/crossref/refs.lua @@ -13,7 +13,7 @@ function resolveRefs() local function add_ref_prefix(ref, ref_type, prefix) local category = crossref.categories.by_ref_type[ref_type] ref:extend(prefix) - if category == nil or category.space_before_numbering ~= false then + if (category == nil or category.space_before_numbering ~= false) and not _quarto.format.isTypstOutput() then ref:extend({nbspString()}) end end @@ -82,12 +82,13 @@ function resolveRefs() -- so we don't get the fallthrough else clause in latex when custom ref commands -- are in play if category == nil or category.custom_ref_command == nil then - ref:extend({pandoc.RawInline('latex', '\\ref{' .. label .. '}')}) + ref:extend(pandoc.List({pandoc.RawInline('latex', '\\ref{' .. label .. '}')})) end elseif _quarto.format.isAsciiDocOutput() then ref = pandoc.List({pandoc.RawInline('asciidoc', '<<' .. label .. '>>')}) elseif _quarto.format.isTypstOutput() then - ref = pandoc.List({pandoc.RawInline('typst', '@' .. label)}) + ref:insert(1, pandoc.RawInline('typst', '#ref(<' .. label .. '>, supplement: [')) + ref:insert(pandoc.RawInline('typst', '])')) else if not resolve then local refClasses = pandoc.List({"quarto-unresolved-ref"}) From 73650eb4d1eddcbb6e398f3f869ba2a689225e80 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 13 Mar 2025 15:24:29 -0400 Subject: [PATCH 2/4] update test --- .../docs/smoke-all/crossrefs/float/typst/typst-float-1.qmd | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-1.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-1.qmd index a834b34cae6..cfa5fd28afc 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-1.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-1.qmd @@ -7,10 +7,8 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "" - - "@fig-1" - - "@tbl-1" + - "#ref\\(, supplement: \\[Figure\\]\\)" + - "#ref\\(, supplement: \\[Table\\]\\)" - [] --- From c4d3181ac3e9d4e7d426ec1b408b0ed7a5936bee Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 13 Mar 2025 15:31:13 -0400 Subject: [PATCH 3/4] update tests --- .../docs/smoke-all/crossrefs/float/typst/typst-float-3.qmd | 6 ++---- .../docs/smoke-all/crossrefs/float/typst/typst-float-4.qmd | 6 ++---- .../smoke-all/crossrefs/float/typst/typst-jupyter-1.qmd | 3 +-- .../docs/smoke-all/crossrefs/float/typst/typst-knitr-1.qmd | 3 +-- .../smoke-all/crossrefs/float/typst/typst-listings-1.qmd | 3 +-- tests/docs/smoke-all/crossrefs/theorem/theorem-1.qmd | 3 +-- tests/docs/smoke-all/crossrefs/theorem/theorem-2.qmd | 3 +-- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-3.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-3.qmd index d58e08ecb67..584105cd789 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-3.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-3.qmd @@ -7,10 +7,8 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "" - - "@fig-foo" - - "@tbl-foo" + - "#ref\\(, supplement: \\[Figure\\]\\)" + - "#ref\\(, supplement: \\[Table\\]\\)" - "This is a figure" - "This is a table" --- diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-4.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-4.qmd index 5f6a09bb222..b92aa195c98 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-4.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-4.qmd @@ -7,10 +7,8 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "" - - "@fig-foo" - - "@tbl-foo" + - "#ref\\(, supplement: \\[Table\\]\\)" + - "#ref\\(, supplement: \\[Figure\\]\\)" - "#link\\(\"https://www.example.com/\"\\)\\[#.*image\\(\"img/surus.jpg\"\\)\\)" --- diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-jupyter-1.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-jupyter-1.qmd index a875bbaf9e5..61fb1e0a9ad 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-jupyter-1.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-jupyter-1.qmd @@ -7,8 +7,7 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "@fig-plot" + - "#ref\\(, supplement: \\[Figure\\]\\)" - "Plot" - "#.*image\\(\"typst-jupyter-1_files/figure-typst/fig-plot-output-1.svg\"\\)" - [] diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-knitr-1.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-knitr-1.qmd index 26b0a55017b..fd6486601b1 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-knitr-1.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-knitr-1.qmd @@ -8,8 +8,7 @@ _quarto: ensureTypstFileRegexMatches: - - "Plot" - - "" - - "@fig-plot" + - "#ref\\(, supplement: \\[Figure\\]\\)" --- ## Knitr Crossref Figure diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-listings-1.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-listings-1.qmd index e864935452a..64761a49f4b 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-listings-1.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-listings-1.qmd @@ -7,8 +7,7 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "@lst-customers" + - "#ref\\(, supplement: \\[Listing\\]\\)" - "Customers Query" - [] --- diff --git a/tests/docs/smoke-all/crossrefs/theorem/theorem-1.qmd b/tests/docs/smoke-all/crossrefs/theorem/theorem-1.qmd index e59826a27c8..62f3b67a6f3 100644 --- a/tests/docs/smoke-all/crossrefs/theorem/theorem-1.qmd +++ b/tests/docs/smoke-all/crossrefs/theorem/theorem-1.qmd @@ -20,8 +20,7 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "@thm-line" + - "#ref\\(, supplement: \\[Theorem\\]\\)" - "#theorem\\(\"Line\"\\)" - [] markdown: diff --git a/tests/docs/smoke-all/crossrefs/theorem/theorem-2.qmd b/tests/docs/smoke-all/crossrefs/theorem/theorem-2.qmd index 978dac3df0e..d1a5d3275ac 100644 --- a/tests/docs/smoke-all/crossrefs/theorem/theorem-2.qmd +++ b/tests/docs/smoke-all/crossrefs/theorem/theorem-2.qmd @@ -20,8 +20,7 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "@thm-line" + - "#ref\\(, supplement: \\[Theorem\\]\\)" - "#theorem\\(\\)" - - "#theorem\\(\"\"\\)" From c40196827397635e0c130f2a1502b3d51224832d Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 13 Mar 2025 15:54:42 -0400 Subject: [PATCH 4/4] more test updates --- .../smoke-all/crossrefs/float/typst/rawtablecaption.qmd | 3 +-- .../docs/smoke-all/crossrefs/float/typst/typst-float-2.qmd | 6 ++---- .../docs/smoke-all/crossrefs/float/typst/typst-float-6.qmd | 3 +-- tests/docs/smoke-all/crossrefs/theorem/lemma-1.qmd | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/docs/smoke-all/crossrefs/float/typst/rawtablecaption.qmd b/tests/docs/smoke-all/crossrefs/float/typst/rawtablecaption.qmd index 6c5954bda16..ccddf215216 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/rawtablecaption.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/rawtablecaption.qmd @@ -8,8 +8,7 @@ _quarto: ensureTypstFileRegexMatches: - - "This is a caption." - - "" - - "@tbl-1" + - "#ref\\(, supplement: \\[Table\\]\\)" - [] --- diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-2.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-2.qmd index c292e01ac25..c31597efc8e 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-2.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-2.qmd @@ -7,10 +7,8 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "" - - "@fig-foo" - - "@tbl-foo" + - "#ref\\(, supplement: \\[Figure\\]\\)" + - "#ref\\(, supplement: \\[Table\\]\\)" - "This is the figure" - "This is the table" --- diff --git a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-6.qmd b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-6.qmd index 00d1459e77d..47d33daae74 100644 --- a/tests/docs/smoke-all/crossrefs/float/typst/typst-float-6.qmd +++ b/tests/docs/smoke-all/crossrefs/float/typst/typst-float-6.qmd @@ -7,8 +7,7 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "@fig-simple" + - "#ref\\(, supplement: \\[Figure\\]\\)" - "A simple figure" - "#.*image\\(\"img/surus.jpg\"\\)" - [] diff --git a/tests/docs/smoke-all/crossrefs/theorem/lemma-1.qmd b/tests/docs/smoke-all/crossrefs/theorem/lemma-1.qmd index a3f05e0108e..dde405023e5 100644 --- a/tests/docs/smoke-all/crossrefs/theorem/lemma-1.qmd +++ b/tests/docs/smoke-all/crossrefs/theorem/lemma-1.qmd @@ -19,8 +19,7 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - "" - - "@lem-line" + - "#ref\\(, supplement: \\[Lemma\\]\\)" - "#lemma\\(\"Line\"\\)" - [] markdown: