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

Nested paragraphs/empty paragraph in footer #2381

Closed
maelle opened this issue Dec 1, 2023 · 1 comment · Fixed by #2451
Closed

Nested paragraphs/empty paragraph in footer #2381

maelle opened this issue Dec 1, 2023 · 1 comment · Fixed by #2451
Labels
bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues
Milestone

Comments

@maelle
Copy link
Collaborator

maelle commented Dec 1, 2023

I'm exploring a problem we're seeing in an rOpenSci package, where this line

xml2::read_html(rendered, encoding = "UTF-8")

leads to errors such as

librdf error - HTML parser error: Tag nav invalid
librdf error - HTML parser error: Tag main invalid
librdf error - HTML parser error: Tag aside invalid
librdf error - HTML parser error: Tag footer invalid
librdf error - HTML parser error: Unexpected end tag : p
librdf error - HTML parser error: Unexpected end tag : p

Now for pkgdown itself there's no problem but I noticed that because we use markdown_text_block() for building elements of the footer, before that line we have

<div class="pkgdown-footer-left">
  <p><p>Developed by <a href="http://hadley.nz">Hadley Wickham</a>, <a href="https://hesselberthlab.org">Jay Hesselberth</a>, <a href="https://masalmon.eu">Maëlle Salmon</a>, <a href="https://www.posit.co"><img src="https://www.tidyverse.org/posit-logo.svg" alt="Posit" height="16" style="margin-bottom: 3px;"></a>.</p></p>
</div>

which is read by xml2, and then published, as

<div class="pkgdown-footer-left">
  <p></p>
<p>Developed by <a href="http://hadley.nz">Hadley Wickham</a>, <a href="https://hesselberthlab.org">Jay Hesselberth</a>, <a href="https://masalmon.eu">Maëlle Salmon</a>, <a href="https://www.posit.co"><img src="https://www.tidyverse.org/posit-logo.svg" alt="Posit" height="16" style="margin-bottom: 3px;"></a>.</p>
</div>

It doesn't seem to lead to any bug to have the empty paragraph, but to not produce nested paragraphs in the first place maybe

left <- markdown_text_block(paste0(components[structure$left], collapse = " "))

should use markdown_text_inline()?

@hadley
Copy link
Member

hadley commented Apr 11, 2024

If we fix that we'll also need to add some additional margin/padding to the default CSS since without that empty paragraph the footer text is very close to the border.

Are you sure that the problem isn't actually that the footer template includes <p> wrapping the content? I think that's the paragraph tag we want to remove so that it is possible for folks to create multiple paragraph footers if they really want to.

@hadley hadley added bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues labels Apr 11, 2024
@hadley hadley added this to the 2.1.0 milestone Apr 12, 2024
hadley added a commit that referenced this issue Apr 16, 2024
The footer markdown is processed with `markdown_text_block()` so it always produces a block tag, rendering the wrapping `<p>` in the footer unnecessary. The empty paragraph tag ends up at the top of the footer, due to xml2 round trip.

Fixes #2381
hadley added a commit that referenced this issue Apr 17, 2024
The footer markdown is processed with `markdown_text_block()` so it always produces a block tag, rendering the wrapping `<p>` in the footer unnecessary. The empty paragraph tag ends up at the top of the footer, due to xml2 round trip.

Fixes #2381
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this issue Jun 1, 2024
The footer markdown is processed with `markdown_text_block()` so it always produces a block tag, rendering the wrapping `<p>` in the footer unnecessary. The empty paragraph tag ends up at the top of the footer, due to xml2 round trip.

Fixes r-lib#2381
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 front end 🌷 General HTML, CSS, and JS issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants