Skip to content

HTML dependencies are not filtered out from being included in PDF output #1378

@cderv

Description

@cderv

Bug description

This is a minimal reprex after digging into the issue reported in #1108 (comment) where discussion happened in mpadge/quarto-test#1

This is a special case from converting some Bookdown project to Quarto Book, but I believe this is really an issue in Quarto at the end.

TL;DR;: HTML dependencies returned in knit_meta are included in the header when converting to PDF which obviously leads to a LaTeX error.

See this simple example

---
always_allow_html: true
---

```{r}
htmltools::tagList(rmarkdown::html_dependency_font_awesome())
htmltools::div(class="dummy", 
               htmltools::p("HTML content"))
```

By inserting always_allow_html: true, it means that even when converting to PDF the code chunk will be evaluated.

Without it we get an error thrown by rmarkdown

Error:
! Functions that produce HTML output found in document targeting pdf output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: true

Note however that the HTML output will not be visible in non-HTML formats.

By allowing always_allow_html: true, the content will be included in the md file within raw HTML block, which we get also in Quarto

::: {.cell-output-display}

```{=html}
<div class="dummy">
<p>HTML content</p>
</div>
```

:::

This will insure the output is not included in PDF output.

However, Quarto does not filter the HTML dependencies part as it is done in rmarkdown::pdf_document() by has_latex_dependencies(knit_meta)
https://github.com/rstudio/rmarkdown/blob/d23e479017ceec894cc62c6b98f40f4188a4a75f/R/pdf_document.R#L177-L81

This means that the .tex file in Quarto will contain this

\makeatother

<link href="test2_files/libs/font-awesome-5.1.0/css/all.css" rel="stylesheet" />
<link href="test2_files/libs/font-awesome-5.1.0/css/v4-shims.css" rel="stylesheet" />
\KOMAoption{captions}{tableheading}

HTML dependencies are resolved like HTML and inserted in the header part of the template.

We should probably fix this.

quarto check Output

quarto check

[>] Checking Quarto installation......OK
      Version: 99.9.9
      Path: C:\Users\chris\Documents\DEV_R\quarto-cli\package\dist\bin\
      CodePage: 1252

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

[>] Checking Python 3 installation....OK
      Version: 3.9.12
      Path: C:/Users/chris/scoop/apps/pyenv/current/pyenv-win/versions/3.9.12/python.exe
      Jupyter: 4.10.0
      Kernels: bash, julia-1.7, python3

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

(\) Checking R installation...........++ Activating rlang global_entrace

[>] Checking R installation...........OK
      Version: 4.2.0
      Path: C:/PROGRA~1/R/R-42~1.0
      LibPaths:
        - C:/Users/chris/AppData/Local/R/win-library/4.2
        - C:/Program Files/R/R-4.2.0/library
      rmarkdown: 2.14.3

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

quarto tools check Output

quarto tools check
[>] Inspecting tools

Tool         Status                    Installed     Latest
chromium     Up to date                869685        869685
tinytex      External Installation     ---           v2022.07

Rstudio IDE 2022.10.0-daily+64 on Windows 11

Checklist

  • formatted your issue so it is easier for us to read?
  • included a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • documented the quarto version you're running, by pasting the output from running quarto check in the "Quarto Check Output" text area?
  • documented the version of the quarto tools you're running, by providing the output from running quarto tools check in the "Quarto Tools Check Output" text area?
  • documented the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • documented which operating system you're running? If on Linux, please provide the specific distribution as well.
  • upgraded to the latest version, including your versions of R, the RStudio IDE, and relevant R packages?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions