Skip to content

Commit

Permalink
i18n for typst
Browse files Browse the repository at this point in the history
includes change to typst-template.typ which should be reverted
when we get a fix for jgm/pandoc#9724

This also fixes #9854 crash for subfigures with no ids
  • Loading branch information
gordonwoodhull committed Jun 3, 2024
1 parent 7307b1a commit d40b8ec
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 7 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ All changes included in 1.5:
- ([#9671](https://github.com/quarto-dev/quarto-cli/issues/9671)): Reimplement `typst` subfloats to fix subfloat counters.
- ([#9694](https://github.com/quarto-dev/quarto-cli/issues/9694)): Fix default callout (`::: callout ... ::: `) in Typst.
- ([#9722](https://github.com/quarto-dev/quarto-cli/issues/9722)): Resolve data URI images in Typst.
- ([#9555](https://github.com/quarto-dev/quarto-cli/issues/9555)): Text elements in Typst are internationalized.
- Upgrade Typst to 0.11
- Upgrade the Typst template to draw tables without grid lines by default, in accordance with latest Pandoc.

Expand Down
2 changes: 1 addition & 1 deletion src/resources/filters/customnodes/floatreftarget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ end, function(float)
-- luacov: enable
end
local kind = "quarto-float-" .. ref
local supplement = info.name
local supplement = titleString('fig', info.name)
-- FIXME: custom numbering doesn't work yet
-- local numbering = ""
-- if float.parent_id then
Expand Down
2 changes: 1 addition & 1 deletion src/resources/filters/customnodes/theorem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ local function ensure_typst_theorems(reftype)
letted_typst_theorem[reftype] = true
local theorem_type = theorem_types[reftype]
quarto.doc.include_text("in-header", "#let " .. theorem_type.env .. " = thmbox(\"" ..
theorem_type.env .. "\", \"" .. theorem_type.title .. "\")")
theorem_type.env .. "\", \"" .. titleString(reftype, theorem_type.title) .. "\")")
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/resources/filters/layout/pandoc3_figure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function render_pandoc3_figure()
caption = figure.caption.long[1],
kind = "quarto-float-fig",
caption_location = crossref.categories.by_ref_type["fig"].caption_location,
supplement = "Figure",
supplement = titleString('fig', 'Figure'),
})
end
}
Expand Down
6 changes: 3 additions & 3 deletions src/resources/filters/layout/typst.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end, function(layout)
return float.content
-- luacov: enable
end
local supplement = info.name
local supplement = titleString(ref, info.name)

-- typst output currently only supports a single grid
-- as output, so no rows of varying columns, etc.
Expand Down Expand Up @@ -133,12 +133,12 @@ end, function(layout)
_quarto.format.typst.as_typst_content(cells)
}, false))
else
result:insert(make_typst_figure {
result:extend(make_typst_figure {
content = cells,
caption_location = caption_location,
caption = layout.float.caption_long,
kind = kind,
supplement = info.prefix,
supplement = titleString(ref, info.prefix),
numbering = info.numbering,
identifier = layout.float.identifier
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

if abstract != none {
block(inset: 2em)[
#text(weight: "semibold")[Abstract] #h(1em) #abstract
#text(weight: "semibold")[$labels.abstract$] #h(1em) #abstract
]
}

Expand Down
56 changes: 56 additions & 0 deletions tests/docs/smoke-all/typst/typst-i18n.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: "Typst internationalization"
lang: es
abstract: Escribo algo.
format:
typst:
keep-typ: true
_quarto:
tests:
typst:
ensureTypstFileRegexMatches:
- ['Resumen', 'Nota', 'Conjetura']
- []
ensurePdfRegexMatches:
- ['Figura 1', 'Figura 2', 'Figura 3', 'Figura 4', 'Figura 5', 'Figura 6']
- ['Figure 1', 'Figure 2', 'Figure 3', 'Figure 4', 'Figure 5', 'Figure 6']
---

![Marcador]({{< placeholder 300 >}}){#fig-marcador}

![Marcador desconocido]({{< placeholder 300 >}})

::: {#fig-panel layout-ncol=2}

![Marcador]({{< placeholder 200 >}}){#fig-layout-a}

![Marcador]({{< placeholder 200 >}}){#fig-layout-b}

Panels

:::

::: {#fig-panel2 layout-ncol=2}

![Marcador]({{< placeholder 200 >}})

![Marcador]({{< placeholder 200 >}})

Panels

:::


::: {.callout-note}

Información

:::

::: {#cnj-redondo}

# Redondo

El mundo es redondo.

:::

0 comments on commit d40b8ec

Please sign in to comment.