rstudio / webshot2

Take screenshots of web pages from R

Home Page:https://rstudio.github.io/webshot2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

incorrect formatting with rmd_shot

RKonstantinR opened this issue · comments

I created a quarto document using callout blocks and grid.

When I render this document in rstudio the formatting is displayed correctly:
изображение

But when I use rmdshot formatting is not displayed correctly:
изображение

Is there a way to fix this?

Quarto doc:

---
title: "repex"
format:
  html:
    embed-resources: true
    page-layout: full
editor: visual
---

```{r, echo=FALSE, warning=FALSE, message=FALSE}
library(echarts4r)
library(tibble)

```

::: grid
::: g-col-2
::: {.callout-note icon="false"}
## one

1
:::
:::

::: g-col-2
::: {.callout-note icon="false"}
## two

2
:::
:::

::: g-col-2
::: {.callout-note icon="false"}
## three

3
:::
:::

::: g-col-2
::: {.callout-note icon="false"}
## four

4
:::
:::

::: g-col-2
::: {.callout-note icon="false"}
## five

5
:::
:::

::: g-col-2
::: {.callout-note icon="false"}
## six

6
:::
:::
:::

::: grid
::: g-col-2
::: border
::: ticker_name
TEXT
:::

::: board_name
SUBTEXT
:::
:::

::: {.callout-tip appearance="minimal"}
foo: bar

foo: bar

foo: bar
:::
:::

::: g-col-10
```{r, echo=FALSE, message=FALSE, warning=FALSE}

plot(mtcars$cyl)

```
:::
:::

R script:

library(webshot2)

webshot2::rmdshot("test.qmd", file = "tst.png")

The problem is that rmdshot() is specifically tied to the R Markdown format. In other words, it calls rmarkdown::render() or rmarkdown::run() on the input document. So in this case, even though you have a .qmd file, it's being processed with rmarkdown instead of quarto.

You can get around this by first rendering the document to HTML and then calling webshot() on that document. I'll open a new issue to track a feature request for webshot2::qmdshot().

# install.packages("quarto")

quarto::quarto_render("test.qmd")
webshot2::webshot("test.html", file = "test.png")

test

Workaround works as expected, thanks for the help!