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

Empty lines are not formatted correctly in verbatim text #951

Closed
s-fleck opened this issue Dec 26, 2018 · 2 comments · Fixed by #1076
Closed

Empty lines are not formatted correctly in verbatim text #951

s-fleck opened this issue Dec 26, 2018 · 2 comments · Fixed by #1076
Labels
bug an unexpected problem or unintended behavior rd-translation 🎏 wip work in progress
Milestone

Comments

@s-fleck
Copy link

s-fleck commented Dec 26, 2018

Empty lines in verbatim / preformatted text that render correctly inside the R documentation
produce an indent of the following line, instead of an empty line.

So this:

#' ```
#' foo
#' 
#' bar
#' ```

renders as this:

foo
   bar

Example from another r-lib package: processx

@kevinushey
Copy link
Contributor

I think this bug ultimately comes down to parse_section() treating the code chunk as multiple paragraphs:

x <- structure(list(
  structure("\n", class = c("TEXT", "tag")),
  structure("Here is a code section.", class = c("TEXT", "tag")),
  structure(
    list(
      structure("Line 1\n", class = c("VERB", "tag")),
      structure("\n", class = c("VERB", "tag")),
      structure("Line 2\n", class = c("VERB", "tag")),
      structure("\n", class = c("VERB", "tag")),
      structure("Line 3\n", class = c("VERB", "tag"))
    ),
    class = c("tag_preformatted", "tag")
  ),
  structure("\n", class = c("TEXT", "tag"))
),
class = c("tag_details", "tag"))

pkgdown:::parse_section(x, "Details")
#> $title
#> [1] "Details"
#> 
#> $contents
#> [1] "<p>Here is a code section.</p><pre>Line 1"
#> [2] "Line 2"                                   
#> [3] "Line 3\n</pre>"

Created on 2019-04-09 by the reprex package (v0.2.1)

I think parse_section() needs to better understand tag_preformatted blocks.

@hadley hadley added the bug an unexpected problem or unintended behavior label May 17, 2019
@hadley hadley added this to the pkgdown 1.4 milestone May 17, 2019
@jayhesselberth
Copy link
Collaborator

The newline stripping done by split_at_linebreaks() in parse_section() needs to be moved into flatten_para(), where block_tags (e.g. tag_preformatted) are still available.

@jayhesselberth jayhesselberth added the wip work in progress label Jun 30, 2019
jayhesselberth added a commit that referenced this issue Jul 2, 2019
jayhesselberth added a commit that referenced this issue Jul 2, 2019
jayhesselberth added a commit that referenced this issue Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior rd-translation 🎏 wip work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants