Skip to content

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

Closed

Description

@gadenbuie

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 ... -->

Activity

  1. cderv commented on Mar 22, 2022

    @cderv
    Collaborator

    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 ! 😅

  2. added a commit that references this issue on Mar 22, 2022
    b5e2dcb
  3. github-actions commented on Sep 20, 2022

    @github-actions

    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.

  4. locked as resolved and limited conversation to collaborators on Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions