glimpse output encoding issue with pkgdown

I'm seeing some weird glitches in the output of glimpse() when my package vignette gets processed by {pkgdown}. This is a mockup Rmd file to illustrate the problem:

---
title: "stuff"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  rmarkdown::html_vignette:
    toc: true
vignette: >
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteIndexEntry{stuff}
  %\VignetteEncoding{UTF-8}
---

[...]

```{r}
library(dplyr)
glimpse(somedata)
```

looking fine when rendered directly.
However, after running pkgdown::build_site(), the same code output looks like this in comparison:

By the looks of it I suspect some encoding problem, but I haven't found a way to specify UTF-8 elsewhere so that pkgdown also picks it up.

Can you share the version of pkgdown you are using ?

I wonder if you are using the dev version which recently add some changes regarding colored output.

Yes, it's a recent dev version (pkgdown_1.9000.9000.9000), as I was having other issues that are fixed in dev ( to remove a deprecated markdown_github warning if I remember correctly).

Then I believe this is an issue or something related to a recent change.
See NEWS file: Changelog • pkgdown

  • Articles now render output styles created by cli/crayon. This is currently a little fragile: you must use collapse = TRUE and echo = TRUE . Future versions will attempt to relax these restrictions, likely through a new document format.

html_vignette() should default to collapse = TRUE - are you setting it to FALSE ?

Otherwise, this could be an issue and glimpse() is not correctly supported.

You could also try to deactivate any coloring using this in a setup chunk

options(cli.num_colors = 1)

This is not perfect - and maybe this will evolve in the current dev version so that it is easier to config this.

The feature is new so it is normal to have some issue

If you don't want to be bother by a moving dev version, you could install the dev version at a specific commit were the fix you need is included.

that seems to have fixed it, thanks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.