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
51 changes: 51 additions & 0 deletions tests/docs/smoke-all/typst/gt-islands.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "gt - Islands"
format:
typst:
quality: 1
keep-typ: true
html:
quality: 1
format-links: false
_quarto:
tests:
typst:
ensureTypstFileRegexMatches:
- ['#set text\(size: 1.25em , fill: rgb\("#333333"\)\); Large Landmasses of the World']
- []
---

```{r}
library(gt)
library(dplyr)

islands_tbl <-
tibble(
name = names(islands),
size = islands
) |>
arrange(desc(size)) |>
slice(1:10)

gt_tbl <- gt(islands_tbl)

gt_tbl <-
gt_tbl |>
tab_header(
title = "Large Landmasses of the World",
subtitle = "The top ten largest are presented"
)

gt_tbl <-
gt_tbl |>
tab_source_note(
source_note = "Source: The World Almanac and Book of Facts, 1975, page 406."
) |>
tab_source_note(
source_note = md("Reference: McNeil, D. R. (1977) *Interactive Data Analysis*. Wiley.")
)

# Show the gt table
gt_tbl

```
45 changes: 45 additions & 0 deletions tests/docs/smoke-all/typst/pandas-cell-css-rules.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "Pandas - Acting on Data"
format:
typst:
quality: 1
keep-typ: true
html:
quality: 1
format-links: false
references:
- type: website
id: pandas-user-guide
url: https://pandas.pydata.org/pandas-docs/version/2.2.2/user_guide/style.html#Acting-on-the-Index-and-Column-Headers
_quarto:
tests:
typst:
ensureTypstFileRegexMatches:
- [
'table.cell\(fill: rgb\("#ffc0cb"\)\)\[#set text\(fill: white\); 1.867558\]',
'\[#set text\(fill: rgb\("#ff413633"\)\); -0.151357\]'
]
- []
---

```{python}
import pandas as pd
import numpy as np

np.random.seed(0)
df2 = pd.DataFrame(np.random.randn(10,4), columns=['A','B','C','D'])

def style_negative(v, props=''):
return props if v < 0 else None
s2 = df2.style.map(style_negative, props='color:red;')\
.map(lambda v: 'opacity: 20%;' if (v < 0.3) and (v > -0.3) else None)

def highlight_max(s, props=''):
return np.where(s == np.nanmax(s.values), props, '')

# darkblue, pink
s2.apply(highlight_max, props='color:white;background-color:#00008b', axis=0)\
.apply(highlight_max, props='color:white;background-color: #ffc0cb;', axis=1)\
.apply(highlight_max, props='color:white;background-color:purple', axis=None)

```