Shiny Presentation (ioslides): Custom CSS and logo

2019-03-02 18:59发布

问题:

I don't yet have the rep to comment on an answer to an existing question so this a follow-up to the question: Shiny Presentation (ioslides): Custom CSS and logo
This question was thought to be solved by fix 385bb28 on the Rstudio Github site. However, the issue has not resolved on either Windows 7 or Windows 8.

I have several shiny ioslides presentations copied on my home and work machines. On each machine:

.Rmd files are saved with UTF-8 encoding
R version - 3.1.2
Rstudio version - 0.98.1091
rmarkdown version - 0.4.2

When I run the following code on my home machine (Windows 8.1) the logo appears but the css is not applied. Removing Runtime: shiny causes both the logo and css to work as intended

---
title: "Habits"
author: John Doe
date: March 22, 2005
output:
  ioslides_presentation:
    css: temp.css
    logo: logo.png
runtime: shiny
---

## Getting up

- Turn off alarm
- Get out of bed

On my work machine (Windows 7 Enterprise) running the above code results in the following error:

Error: Invalid regular expression 'C:Users\jfreels\AppData\Temp\RtmpW0cpcs\file1d7845d27c4c_files/logo.gif', reason 'Invalid back reference'

This error appears to fall in line with a discussion on the Rstudio site: https://support.rstudio.com/hc/communities/public/questions/203671936-Invalid-Back-Reference-when-running-a-Shiny-app

If I remove just the logo callout in the YAML header, the presentation successfully compiles but custom css doesn't appear. Again, removing Runtime: shiny causes both the css and the logo to function properly.

Finally, in Windows 7 Enterprise if I remove the logo callout in the YAML header but include a plot in one of the slides, i.e.

---
title: "Plot"
author: John Doe
date: March 22, 2005
output: ioslides_presentation
runtime: shiny
---

## Plot
```{r fig.show='asis'}
plot(cars)
```

I get the same 'Invalid back reference' error as discussed above (except the location of the error is listed as chunk-1). BUT, if I change the chunk argument to fig.show='hide' the error does not appear and the presentation compiles successfully.

Thanks in advance for your help is solving this issue.

回答1:

This problem can be fixed by installing version 0.5.2 of the rmarkdown package. Currently this is the development version and can be installed from GitHub using:

install.packages("devtools")
library(devtools)
devtools::install_github("rstudio/rmarkdown")