grimbough / msmbstyle

Tufte inspired bookdown template
https://www-huber.embl.de/users/msmith/msmbstyle/
59 stars 18 forks source link

Add text to the footer #13

Closed ericpgreen closed 5 years ago

ericpgreen commented 5 years ago

Is there a way to define footer text in the YAML? The Modern Statistics example has additional footer text.

Screenshot 2019-04-10 11 23 20

If not in the YAML, what's the best way to add text? I see that the existing "Page built" text is defined in msmb_html.R

'<p class="build-date">Page built: ', as.character(Sys.Date()), '</p>',

Dumb question, but would I need to fork this repo and add the text I want to this file, or is there a simpler solution with the existing package?

grimbough commented 5 years ago

I actually add that as a post processing step after I've rendered the HTML using the following function:

add_denbi <- function(html_file) {
  html <- xfun::read_utf8(html_file) 
  date_lines <- which(str_detect(html, "[0-9]{4}-[0-9]{2}-[0-9]{2}"))

  html[rev(date_lines)[1]] <- paste0(html[rev(date_lines)[1]],
  '</p><p class="build-date">\nSupport for maintaining the online version of this book is provided by <a href="http://www.denbi.de">de.NBI</a>
  <img src="images/denbi.png" style="vertical-align: text-top;height: 16px"><br>\nFor website support please contact msmith@embl.de')
  xfun::write_utf8(html, html_file)
}

##  apply to all chapters
html_files <- list.files('book', pattern = ".html", full.names = TRUE)
lapply(html_files, add_denbi)

Also, thanks for the continued interest. I'm currently on vacation so if it looks like I'm ignoring github that's because I pretty much am, but I'll try to respond to issues etc in the next few weeks once I'm back home.

ericpgreen commented 5 years ago

Nice, Mike. Works great. Enjoy some time away.

On Wed, Apr 10, 2019 at 12:05 PM Mike Smith notifications@github.com wrote:

I actually add that as a post processing step after I've rendered the HTML using the following function:

add_denbi <- function(html_file) { html <- xfun::read_utf8(html_file) date_lines <- which(str_detect(html, "[0-9]{4}-[0-9]{2}-[0-9]{2}"))

html[rev(date_lines)[1]] <- paste0(html[rev(date_lines)[1]], '

\nSupport for maintaining the online version of this book is provided by de.NBI
\nFor website support please contact msmith@embl.de') xfun::write_utf8(html, html_file) }

apply to all chapters

html_files <- list.files('book', pattern = ".html", full.names = TRUE) lapply(html_files, add_denbi)


Also, thanks for the continued interest. I'm currently on vacation so if it looks like I'm ignoring github that's because I pretty much am, but I'll try to respond to issues etc in the next few weeks once I'm back home.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/grimbough/msmbstyle/issues/13#issuecomment-481754750, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhWgWnGK28IDi-Q797nZgQe5JJYHqSQks5vfgvdgaJpZM4cnh2h .