Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions src/resources/filters/crossref/refs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ _quarto:
ensureTypstFileRegexMatches:
-
- "This is a caption."
- "<tbl-1>"
- "@tbl-1"
- "#ref\\(<tbl-1>, supplement: \\[Table\\]\\)"
- []
---

Expand Down
6 changes: 2 additions & 4 deletions tests/docs/smoke-all/crossrefs/float/typst/typst-float-1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<tbl-1>"
- "<fig-1>"
- "@fig-1"
- "@tbl-1"
- "#ref\\(<fig-1>, supplement: \\[Figure\\]\\)"
- "#ref\\(<tbl-1>, supplement: \\[Table\\]\\)"
- []
---

Expand Down
6 changes: 2 additions & 4 deletions tests/docs/smoke-all/crossrefs/float/typst/typst-float-2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<fig-foo>"
- "<tbl-foo>"
- "@fig-foo"
- "@tbl-foo"
- "#ref\\(<fig-foo>, supplement: \\[Figure\\]\\)"
- "#ref\\(<tbl-foo>, supplement: \\[Table\\]\\)"
- "This is the figure"
- "This is the table"
---
Expand Down
6 changes: 2 additions & 4 deletions tests/docs/smoke-all/crossrefs/float/typst/typst-float-3.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<fig-foo>"
- "<tbl-foo>"
- "@fig-foo"
- "@tbl-foo"
- "#ref\\(<fig-foo>, supplement: \\[Figure\\]\\)"
- "#ref\\(<tbl-foo>, supplement: \\[Table\\]\\)"
- "This is a figure"
- "This is a table"
---
Expand Down
6 changes: 2 additions & 4 deletions tests/docs/smoke-all/crossrefs/float/typst/typst-float-4.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<fig-foo>"
- "<tbl-foo>"
- "@fig-foo"
- "@tbl-foo"
- "#ref\\(<tbl-foo>, supplement: \\[Table\\]\\)"
- "#ref\\(<fig-foo>, supplement: \\[Figure\\]\\)"
- "#link\\(\"https://www.example.com/\"\\)\\[#.*image\\(\"img/surus.jpg\"\\)\\)"
---

Expand Down
3 changes: 1 addition & 2 deletions tests/docs/smoke-all/crossrefs/float/typst/typst-float-6.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<fig-simple>"
- "@fig-simple"
- "#ref\\(<fig-simple>, supplement: \\[Figure\\]\\)"
- "A simple figure"
- "#.*image\\(\"img/surus.jpg\"\\)"
- []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<fig-plot>"
- "@fig-plot"
- "#ref\\(<fig-plot>, supplement: \\[Figure\\]\\)"
- "Plot"
- "#.*image\\(\"typst-jupyter-1_files/figure-typst/fig-plot-output-1.svg\"\\)"
- []
Expand Down
3 changes: 1 addition & 2 deletions tests/docs/smoke-all/crossrefs/float/typst/typst-knitr-1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ _quarto:
ensureTypstFileRegexMatches:
-
- "Plot"
- "<fig-plot>"
- "@fig-plot"
- "#ref\\(<fig-plot>, supplement: \\[Figure\\]\\)"
---

## Knitr Crossref Figure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<lst-customers>"
- "@lst-customers"
- "#ref\\(<lst-customers>, supplement: \\[Listing\\]\\)"
- "Customers Query"
- []
---
Expand Down
3 changes: 1 addition & 2 deletions tests/docs/smoke-all/crossrefs/theorem/lemma-1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<lem-line>"
- "@lem-line"
- "#ref\\(<lem-line>, supplement: \\[Lemma\\]\\)"
- "#lemma\\(\"Line\"\\)"
- []
markdown:
Expand Down
3 changes: 1 addition & 2 deletions tests/docs/smoke-all/crossrefs/theorem/theorem-1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<thm-line>"
- "@thm-line"
- "#ref\\(<thm-line>, supplement: \\[Theorem\\]\\)"
- "#theorem\\(\"Line\"\\)"
- []
markdown:
Expand Down
3 changes: 1 addition & 2 deletions tests/docs/smoke-all/crossrefs/theorem/theorem-2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- "<thm-line>"
- "@thm-line"
- "#ref\\(<thm-line>, supplement: \\[Theorem\\]\\)"
- "#theorem\\(\\)"
-
- "#theorem\\(\"\"\\)"
Expand Down
Loading