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

Paragraph breaks are lost in subsections #991

Closed
gustavdelius opened this issue Apr 3, 2019 · 10 comments
Closed

Paragraph breaks are lost in subsections #991

gustavdelius opened this issue Apr 3, 2019 · 10 comments

Comments

@gustavdelius
Copy link
Contributor

@gustavdelius gustavdelius commented Apr 3, 2019

The following roxygen block illustrates the issue. This leads to a two-paragraph subsection in the Rd file, but pkgdown removes the paragraph break when converting this to html, where both are put on the same line as "First paragraph Second paragraph".

#' Testing subsections
#' 
#' @section A section:
#' \subsection{A subsection}{
#'   First paragraph
#'   
#'   Second paragraph
#' }
#' @name testing
@jayhesselberth

This comment has been hidden.

@gustavdelius
Copy link
Contributor Author

@gustavdelius gustavdelius commented Apr 5, 2019

It is indeed related to #819. In fact, any paragraph break within braces is removed by pkgdown. For example

#' Hello
#'
#' testing
#'
#' \strong{One paragraph
#'
#' another paragraph}

Gives two bold paragraphs in the .Rd file but only one bold line in the .html file produced by pkgdown.

@kevinushey

This comment has been hidden.

@hadley
Copy link
Member

@hadley hadley commented May 17, 2019

Would someone mind creating some minimal reprexes using rd2html()?

@hadley hadley added this to the pkgdown 1.4 milestone May 17, 2019
@jayhesselberth

This comment has been hidden.

@gustavdelius

This comment has been hidden.

@jayhesselberth
Copy link
Collaborator

@jayhesselberth jayhesselberth commented Jul 3, 2019

Rendering of verbatim blocks was fixed in #1076, but this doesn't fix subsection rendering.

@jayhesselberth
Copy link
Collaborator

@jayhesselberth jayhesselberth commented Jul 3, 2019

tag_subsection blocks need to be handled specially in flatten_para.

The current HTML output looks like:

<h3>A subsection</h3>
 
First paragraph

Second paragraph

but needs to look like:

<h3>A subsection</h3>
<p>
First paragraph
</p>

<p>
Second paragraph
</p>

@hadley
Copy link
Member

@hadley hadley commented Aug 27, 2019

Minimal reprex:

x <- "\\subsection{A subsection}{
  First para
  
  Second para
}"

writeLines(pkgdown:::rd2html(x))
#> <h3>A subsection</h3>
#> 
#> First para
#> 
#> Second para

Created on 2019-08-27 by the reprex package (v0.3.0)

@hadley
Copy link
Member

@hadley hadley commented Aug 27, 2019

Ooops, this was actually an easy one: as_html.tag_subsection() needs to call flatten_para(), not flatten_text()

@hadley hadley closed this in ccb2410 Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants