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

htmlPreserve() wraps input <p> tag in some cases #305

Closed
cpsievert opened this issue Dec 16, 2021 · 0 comments · Fixed by #306
Closed

htmlPreserve() wraps input <p> tag in some cases #305

cpsievert opened this issue Dec 16, 2021 · 0 comments · Fixed by #306

Comments

@cpsievert
Copy link
Collaborator

Minimal reprex of the problem behind rstudio/flexdashboard#379

This issue was introduced when we added the htmltools.preserve.raw in #191, which rmarkdown now sets to preserve HTML via pandoc's raw attributes rather than our using own hand-rolled solution.

What happens is essentially:

withr::with_options(
  list(htmltools.preserve.raw = TRUE), 
  htmlPreserve("<iframe></iframe>")
)
#> [1] "`<iframe></iframe>`{=html}"

And since this is using an inline code block, pandoc wraps the HTML in a <p>, which can have numerous unintended consequences, including changing the computed height on the input HTML (as we're seeing in rstudio/flexdashboard#379)

# inline form
❯ pandoc -t html
`<iframe></iframe>`{=html}
^Z
<p><iframe></iframe></p>
# block form
❯ pandoc -t html
```{=html}
<iframe></iframe>
```
^Z
<iframe></iframe>

After running this through @jjallaire, it seems like the best way forward is to just not use the inline form at all since:

  1. It doesn't seem like there's any real use case for wrapping the input in <p> (and if there is, it seems easy enough to add it to the input?)
  2. This should generally yield the same result as using options(htmltools.preserve.raw = TRUE), which has been around much longer

cc @cderv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant