Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trailing triple backticks disappear #2237

Closed
idavydov opened this issue Nov 16, 2022 · 3 comments · Fixed by #2238
Closed

trailing triple backticks disappear #2237

idavydov opened this issue Nov 16, 2022 · 3 comments · Fixed by #2238
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@idavydov
Copy link

idavydov commented Nov 16, 2022

I have the following roxygen code:

#' ````
#' ## Some header
#'
#' ```{r results='asis'}
#' some code
#' ```
#'
#' ````

When I call devtools::document(), the .Rd file looks fine:

\preformatted{## Some header

```\{r results='asis'\}
some code
```

}

However, when I run pkgdown::build_site(), the trailing backticks disappear:

## Some header

```{r results='asis'}
some code
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.0 (2022-04-22)
#>  os       Fedora 33 (Container Image)
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US:en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Zurich
#>  date     2022-11-16
#>  pandoc   2.17.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cachem        1.0.6   2021-08-19 [2] CRAN (R 4.2.0)
#>  cli           3.4.1   2022-09-23 [2] CRAN (R 4.2.0)
#>  digest        0.6.30  2022-10-18 [2] CRAN (R 4.2.0)
#>  evaluate      0.18    2022-11-07 [2] CRAN (R 4.2.0)
#>  fastmap       1.1.0   2021-01-25 [2] CRAN (R 4.2.0)
#>  fs            1.5.2   2021-12-08 [5] CRAN (R 4.2.0)
#>  glue          1.6.2   2022-02-24 [2] CRAN (R 4.2.0)
#>  highr         0.9     2021-04-16 [2] CRAN (R 4.2.0)
#>  htmltools     0.5.3   2022-07-18 [2] CRAN (R 4.2.0)
#>  knitr         1.40    2022-08-24 [2] CRAN (R 4.2.0)
#>  lifecycle     1.0.3   2022-10-07 [2] CRAN (R 4.2.0)
#>  magrittr      2.0.3   2022-03-30 [2] CRAN (R 4.2.0)
#>  memoise       2.0.1   2021-11-26 [2] CRAN (R 4.2.0)
#>  pkgdown     * 2.0.6   2022-07-16 [2] CRAN (R 4.2.0)
#>  purrr         0.3.5   2022-10-06 [2] CRAN (R 4.2.0)
#>  R.cache       0.16.0  2022-07-21 [2] CRAN (R 4.2.0)
#>  R.methodsS3   1.8.2   2022-06-13 [2] CRAN (R 4.2.0)
#>  R.oo          1.25.0  2022-06-12 [2] CRAN (R 4.2.0)
#>  R.utils       2.12.2  2022-11-11 [2] CRAN (R 4.2.0)
#>  reprex        2.0.2   2022-08-17 [2] CRAN (R 4.2.0)
#>  rlang         1.0.6   2022-09-24 [2] CRAN (R 4.2.0)
#>  rmarkdown     2.18    2022-11-09 [2] CRAN (R 4.2.0)
#>  rstudioapi    0.14    2022-08-22 [2] CRAN (R 4.2.0)
#>  sessioninfo   1.2.2   2021-12-06 [2] CRAN (R 4.2.0)
#>  stringi       1.7.8   2022-07-11 [2] CRAN (R 4.2.0)
#>  stringr       1.4.1   2022-08-20 [2] CRAN (R 4.2.0)
#>  styler        1.8.1   2022-11-07 [2] CRAN (R 4.2.0)
#>  withr         2.5.0   2022-03-03 [2] CRAN (R 4.2.0)
#>  xfun          0.34    2022-10-18 [2] CRAN (R 4.2.0)
#>  yaml          2.3.6   2022-10-18 [2] CRAN (R 4.2.0)
#> 
#> <removed>
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@maelle maelle added the bug an unexpected problem or unintended behavior label Nov 22, 2022
@maelle
Copy link
Collaborator

maelle commented Nov 22, 2022

First notes

  • it'd be better to add the language to the code i.e.
#' ````markdown
#' ## Some header
#'
#' ```{r results='asis'}
#' some code
#' ```
#'
#' ````
  • the problem happens in tweak_highlight_other()

@maelle
Copy link
Collaborator

maelle commented Nov 22, 2022

a fix would be to replace

md <- paste0("```", lang, "\n", xml2::xml_text(code), "\n```")

with

md <- paste0("`````", lang, "\n", xml2::xml_text(code), "\n`````")

🤔 (I tested it, it works)

@maelle
Copy link
Collaborator

maelle commented Nov 25, 2022

#2238

@maelle maelle added this to the 2.0.7 milestone Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants