coatless / quarto-webr

Quarto Extension to Embed webR for HTML Documents, RevealJS, Websites, Blogs, and Books.

Home Page:https://quarto-webr.thecoatlessprofessor.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Output being excessively truncated, causing gt to print incomplete tables

erikvona opened this issue · comments

Bug description

The output of chunks in WebR is being heavily truncated. This causes the package gt to malfunction, since a table contains so much CSS it is pretty much always truncated

Steps to reproduce

```{webr-r}
#| results: asis
webr::install("gt")
gt::gt(mtcars) |> print(view = FALSE)
```

Expected: The full table is printed. Actual: a warning is printed (Warning: printing of extremely long output is truncated) and only the table headers are printed.

This can be ameliorated by chunking the output, e.g.:

```{webr-r}
#| results: asis
webr::install("gt")
fix_print <- function(characters, max_print = 100){
  i <- 1
  while(nchar(characters) >= i){
    cat(substring(characters, i, i + max_print ))
    i <- i + max_print + 1
  }
}
gt::gt(mtcars) |> gt::as_raw_html(inline_css = FALSE) |> fix_print()
```

I've tracked the error message to this line in WebR, but the WebR REPL does not produce this error and can produce the full output.

Your environment

Online: on https://quarto-webr.thecoatlessprofessor.com/demos/qwebr-code-cell-options.html#results-option there's a chunk with #| results: asis which can be used to reproduce this behavior.

Also, Windows 10, R 4.4.0.

Quarto check output

Quarto 1.5.43
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.5.43
      Path: C:\Program Files\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[>] Checking LaTeX....................OK
      Tex:  (not detected)

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.9.6
      Path: C:/Python39/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with py -m pip install jupyter

[>] Checking R installation...........OK
      Version: 4.3.2
      Path: C:/R/r_lang
      LibPaths:
        - C:/r-checkpoint/no-checkpoint
        - C:/R/library
      knitr: 1.45
      rmarkdown: 2.25

[>] Checking Knitr engine render......OK

@erikvona going to upstream a portion of the printing cut-off to the main webR repo. The difference with the webR REPL vs the quarto-webr code cell is we're using Shelter.captureR() instead of Console to obtain and process output.

The later portion regarding the asis is related to #166

George expanded the buffer in webR. So the latest version has been fixed. It'll propagate out in either v0.3.4/v0.4.0.