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
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ function render_typst_css_property_processing()
elseif k == 'font-size' then
cell.attributes['typst:text:size'] = _quarto.format.typst.css.translate_length(v, _warnings)
elseif k == 'font-weight' then
cell.attributes['typst:text:weight'] = _quarto.format.typst.css.quote(_quarto.format.typst.css.translate_font_weight(v, _warnings))
local translated_fw = _quarto.format.typst.css.translate_font_weight(v, _warnings)
-- unsupported font-weight values will be returned as nil
if translated_fw then
cell.attributes['typst:text:weight'] = _quarto.format.typst.css.quote(translated_fw)
end
elseif k == 'font-style' then
cell.attributes['typst:text:style'] = _quarto.format.typst.css.quote(v)
elseif k == 'vertical-align' then
Expand Down
53 changes: 53 additions & 0 deletions tests/docs/smoke-all/typst/great-tables-oceania.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "Great Tables - Oceania"
format: typst
_quarto:
tests:
typst:
printsMessage:
level: INFO
regex: 'invalid font weight initial'
---

```{=typst}
#set page(numbering: none)
```

```{python}
#| classes: plain
from great_tables import GT
from great_tables.data import countrypops
import polars as pl
import polars.selectors as cs

# Get vectors of 2-letter country codes for each region of Oceania
oceania = {
"Australasia": ["AU", "NZ"],
"Melanesia": ["NC", "PG", "SB", "VU"],
"Micronesia": ["FM", "GU", "KI", "MH", "MP", "NR", "PW"],
"Polynesia": ["PF", "WS", "TO", "TV"],
}

# Create a dictionary mapping country to region (e.g. AU -> Australasia)
country_to_region = {
country: region for region, countries in oceania.items() for country in countries
}

wide_pops = (
pl.from_pandas(countrypops)
.filter(
pl.col("country_code_2").is_in(list(country_to_region))
& pl.col("year").is_in([2000, 2010, 2020])
)
.with_columns(pl.col("country_code_2").replace(country_to_region).alias("region"))
.pivot(index=["country_name", "region"], columns="year", values="population")
.sort("2020", descending=True)
)

(
GT(wide_pops, rowname_col="country_name", groupname_col="region")
.tab_header(title="Populations of Oceania's Countries in 2000, 2010, and 2020")
.tab_spanner(label="Total Population", columns=cs.all())
.fmt_integer()
)
```
3 changes: 3 additions & 0 deletions tests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ dependencies = [
"papermill>=2.6.0",
"seaborn>=0.13.2",
"shiny>=1.2.0",
"great-tables>=0.17.0",
"polars>=1.29.0",
"pyarrow>=20.0.0",
]
Loading
Loading