Why are pilcrow symbols (¶) appearing in my HTML document headers?

I stopped using Rstudio/R for a few months because my employer wanted to use other software. I updated R, Rstudio, and all my packages when I started using it again.

Now all of my Rmarkdown reports have unwanted pilcrow (¶) symbols in my YAML headers when I use CSS formatting.

Would someone please help me understand why this quirk is happening now? I'd really like to drop those symbols.

 h1 {
     font-size: 36px;
     font-weight: bold;
     font-family: Helvetica;
     color: #CC0000;
 }

 h2 {
     font-size: 18px;
     font-weight: normal;
     font-family: Helvetica;
     color: #000000;
 }

 h3 {
     font-size: 15px;
     font-weight: normal;
     font-family: Helvetica;
     color: #000000;
 }

I'm not sure why the pilcrows appear, but here is one way to drop them.

---
title: "`r htmltools::HTML('<h1>Why are there pilcrows here?</h1>')`"
author: "`r htmltools::HTML('<h2>And here?</h2>')`"
date: "`r htmltools::HTML('<h3>And here too?</h3>')`"
output: html_document
---
```{css formatting, echo=FALSE}

h1 {
     font-size: 36px;
     font-weight: bold;
     font-family: Helvetica;
     color: #CC0000;
 }

 h2 {
     font-size: 18px;
     font-weight: normal;
     font-family: Helvetica;
     color: #000000;
 }

 h3 {
     font-size: 15px;
     font-weight: normal;
     font-family: Helvetica;
     color: #000000;
 }

See duplicate post here where this was answered

Also you got that because your code is not that correct. It was just hidden before. You don’t need html tag in your title and other fields. Especially because they will be already including in h1 or h2.

scottyd22, cderv, thank you for your solutions.

@cderv, I appreciate the details in the post you linked me to. Is there a way to incorporate a third format type, h3, without using html tags?

If not, then I'm content with the pandoc explanation and htmltools workaround.

You mean for one of the YAML fields ?

Those are in the HTML templates used by default, so you would need to change it or postprocess the HTML
h3 is used for subtitles as you can see.

Next Pandoc version should have a no pilcrows by the way. But again, the pilcrows are there because the field value is parsed as blocks and not inlines only.

Thank you, that removed the mystery.

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.