xaringan
xaringan copied to clipboard
Spaces and inline R YAML strings
I'm trying to add a twitter icon to the subtitle YAML parameter. Here's a reproducible piece of working code which produces the output I'm after.
---
title: "Presentation Ninja"
subtitle: ' `r fontawesome::fa("twitter", fill = "steelblue")` @ClausEkstrom'
author: "Claus Ekstrøm"
date: "Some day"
output:
xaringan::moon_reader:
lib_dir: libs
css: ['default']
seal: true
nature:
ratio: '16:9'
slideNumberFormat: '%current%'
highlightStyle: ir-black
highlightLines: true
countIncrementalSlides: false
beforeInit: "js/zoom.js"
---
Ohoy sailor
Notice the space between the backtick and the quote on the subtitle
line. If I remove that (which I did initially), such that it beomes
subtitle: '`r fontawesome::fa("twitter", fill = "steelblue")` @ClausEkstrom'
then I get no twitter icon. I have no idea why I should get different results from these two formats.
If I look at the resulting html-code then I can see why the output is different, since the working code (first example above) produces one long line
## <svg style="height:0.8em;top:.04em;position:relative;fill:steelblue;" viewBox="0 0 512 512"><path d="M459.37 151.716c.325 ... 39.308-52.628 54.253z"/></svg> <span class="citation">@ClausEkstrom</span>
while the code without the space produces 4 lines including a <p> ... </p>
:
## <svg style="height:0.8em;top:.04em;position:relative;fill:steelblue;" viewBox="0 0 512 512">
<path d="M459.37 151.716c.325 ... 39.308-52.628 54.253z"/>
</svg>
<p><span class="citation">@ClausEkstrom</span></p>
Why is that and shouldn't they give the same?