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"}) 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-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\\]\\)" - [] --- 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-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-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/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/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: 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\\(\"\"\\)"