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

shinyrmd needs additional empty lines between content and knit meta #2336

Closed
gadenbuie opened this issue Mar 22, 2022 · 2 comments · Fixed by #2337
Closed

shinyrmd needs additional empty lines between content and knit meta #2336

gadenbuie opened this issue Mar 22, 2022 · 2 comments · Fixed by #2337

Comments

@gadenbuie
Copy link
Member

gadenbuie commented Mar 22, 2022

If a shiny prerendered or shinyrmd source .Rmd ends with a single newline, the additional content added to support the prerendered format are added immediately after the content. This breaks pandoc's handling of the last line, e.g. it won't be processed into a paragraph tag.

Source

---
title: "shinyrmd issue"
output: 
  html_document:
    keep_md: true
runtime: shinyrmd
---

Here's some standard content, notice only one final empty line in the source file.

Edit: it seems that GitHub formatting removes the trailing empty line of the code block above. It's important that there is only one (or no) final empty line in the source file.

Markdown

---
title: "shinyrmd issue"
output: 
  html_document:
    keep_md: true
runtime: shinyrmd
---

Here's some standard content, notice only one final empty line in the source file.
<!--html_preserve-->
<script type="application/shiny-prerendered" data-context="dependencies">
<!-- ... inline json and other things ... -->

HTML

<!-- ... truncated ... -->

Here’s some standard content, notice only one final empty line in the
source file. <!--html_preserve-->
<script type="application/shiny-prerendered" data-context="dependencies">
<!-- ... inline json and other things ... -->

If only one more line were added at the end of the Rmd source file, we'd have this HTML:

<!-- ... truncated ... -->

<p>Here’s some standard content, notice only one final empty line in the
source file.</p>
<!--html_preserve-->
<script type="application/shiny-prerendered" data-context="dependencies">
<!-- ... inline json and other things ... -->
@cderv
Copy link
Collaborator

cderv commented Mar 22, 2022

Thanks. That is quite a specific issue ! Indeed Pandoc won't see that as a paragraph. I guess adding a blank line before inserting the preserve part should be enough.

I noticed that we are still using <!--html_preserve--> keyword. I wonder if we should switch to using Pandoc's raw block but I guess there is no need and too many risk to break something 😄

Curious how did you found this one ! 😅

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants