From d51a610291c65f18f59fc815a62749d625e184af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 16 Sep 2024 14:28:23 +0200 Subject: [PATCH] feat: use katex for math --- inst/pkgdown/_pkgdown.yml | 1 + vignettes/rendering.Rmd | 203 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 vignettes/rendering.Rmd diff --git a/inst/pkgdown/_pkgdown.yml b/inst/pkgdown/_pkgdown.yml index 82c85a4..6c47ff6 100644 --- a/inst/pkgdown/_pkgdown.yml +++ b/inst/pkgdown/_pkgdown.yml @@ -6,6 +6,7 @@ template: base_font: {google: "Roboto Condensed"} heading_font: {google: "Playfair Display"} code_font: {google: "Roboto Mono"} + math-rendering: katex authors: Poisson Consulting: diff --git a/vignettes/rendering.Rmd b/vignettes/rendering.Rmd new file mode 100644 index 0000000..78c8ca6 --- /dev/null +++ b/vignettes/rendering.Rmd @@ -0,0 +1,203 @@ +--- +title: "Output Rendering" +subtitle: "Subtitle is skipped from the TOC" +author: "Author is skipped from the TOC" +date: "Date is skipped from the TOC" +--- + +```{r} +# all from https://github.com/r-lib/pkgdown/blob/bbf246ea0e115fa39486bee5be80f91903c0081b/vignettes/test/rendering.Rmd#L1 +#| include: FALSE +knitr::opts_chunk$set(collapse = TRUE, comment = "#>") +``` + +This vignette tests pkgdown output rendering for several use cases. + +## Footnotes + +Yay[^footnote] + +[^footnote]: Including **footnotes**! 😁 + +## Figures + +```{r} +#| fig.alt: Test plot +plot(1:10) +``` + + +## Details tag + +
+This should only be shown when required +
+ +
+Multiple paragraphs +First paragraph + +Second paragraph +
+ +
+Some R code + +```{r} +1 + 2 +``` +
+ +## Tables + +| col 1 | col 2 | col 3 | col 4 | +|:---------------|:-----------|:-------:|:---------:| +| Brightness | Total brightness, total reflectance, spectral intensity | $$y = x^2$$ | test | + +## Math + +$$f(x) = \dfrac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{(x-\mu^2)}{2\sigma^2}}$$ + +Inline equations: $y=x^2$ + +## Code + +### Line width + +```{r} +pkgdown:::ruler() + +cat(rep("x ", 100), sep = "") +cat(rep("xy", 100), sep = "") +``` + +### Should be highlighted + +Valid R code in `\preformatted{}`: + +``` +mean(a + 1) +``` + +R code in `R` block: + +```R +mean(a + 1) +``` + +R code in `r` block: + +```R +mean(a + 1) +``` + +Yaml + +```yaml +yaml: [a, 1] +``` + +### Shouldn't be highlighted + +Non-R code in `\preformatted{}` + +``` +yaml: [a, b, c] +``` + +### Crayon + +```{r} +cat(cli::col_red("This is red"), "\n") +cat(cli::col_blue("This is blue\n"), "\n") + +message(cli::col_green("This is green")) + +warning(cli::style_bold("This is bold")) +``` +Some text + +```{r} +#| error: TRUE +stop(cli::style_italic("This is italic")) +``` + +Some more text + +## Quoted text + +> Single-line quote about something miscellaneous. + +| Flush +| 1 space indent +| 2 space indent +| 3 space indent + +## This section is unnumbered {-} + +There should however be no bug here! + +## Tabsets + +### Tabset with pills {.tabset .tabset-pills} + +#### Tab 1 + +blablablabla + +```r +1 + 1 +``` + +Should be "cool" heading below + +##### cool + +Stuff + +#### Tab 2 + +blop + +### Tabset without pills {.tabset} + +#### Tab 1 + +something nice + +```{r} +#| fig.alt: Another test plot +plot(1:42) +``` + +#### Tab 2 {.active} + +This tab should be active + +### Fading tabset {.tabset .tabset-fade} + +#### English + +Hello! + +#### French + +Bonjour! + +#### German + +Guten tag. + +## Deep headings + +### Heading 3 + +#### Heading 4 + +##### Heading 5 + +## Very long words + +This word should be broken across multiple lines on mobile, rather than making the page scroll horizontally: + +Ccccccccccccaaaaaaaaaaaaaaatttttttttttttttttssssssssssssssss