Handling Empty Paragraphs from R Markdown
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
From time to time I find empty paragraph tags (<p></p>
) inserted into my HTML when knitting an R Markdown document.
Beyond being an affront to my OCD, these empty tags are mostly just an irritation. But if I’m trying to produce a very specific layout, then the extra space allocated to them can become a real annoyance.
These tags seem to occur when I have a particular configuration of native HTML tags in the .Rmd
file. I did try to understand precisely what was causing them, but lost patience. It turns out that it’s easier to simply accept them, rendering them invisible with the following neat CSS rule.
p:empty { display: none; }
That will identify all empty paragraph tags using the :empty
pseudo-class, then hide them by setting display
to none
.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.