Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 772223e

Browse files
committed
get rid of _render.R, and remove html_book/tufte_html_book formats so the HTML formats won't overwrite each other under the _book directory; also tweaked _publish.R so I can still publish bootstrap/tufte styles to bookdown.org
1 parent d34c0b3 commit 772223e

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

_output.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ bookdown::gitbook:
88
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
99
edit:
1010
link: https://github.com/rstudio/bookdown-demo/edit/master/inst/examples/%s
11-
text: "Edit"
12-
bookdown::tufte_html_book:
13-
css: [style.css, toc.css]
1411
bookdown::pdf_book:
1512
includes:
1613
in_header: preamble.tex
1714
latex_engine: xelatex
1815
citation_package: natbib
19-
bookdown::html_book:
20-
css: [style.css, toc.css]
16+
bookdown::epub_book: default

_publish.R

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
# publish the book with other styles
1+
# publish the book with differnet HTML styles; you should not need this script
2+
3+
# default formats
4+
formats = c(
5+
'bookdown::pdf_book', 'bookdown::epub_book', 'bookdown::gitbook'
6+
)
27

38
unlink('_book', recursive = TRUE)
4-
bookdown:::Rscript('_render.R')
9+
10+
# render the book to all formats unless they are specified via command-line args
11+
for (fmt in formats) {
12+
cmd = sprintf("bookdown::render_book('index.Rmd', '%s', quiet = TRUE)", fmt)
13+
res = bookdown:::Rscript(c('-e', shQuote(cmd)))
14+
if (res != 0) stop('Failed to compile the book to ', fmt)
15+
}
16+
517
bookdown::publish_book('bookdown-demo')
618

719
x = readLines('index.Rmd')
@@ -10,12 +22,18 @@ s = paste0('title: "A Minimal Book Example (', c('Bootstrap', 'Tufte'), ' Style)
1022
for (fmt in c('html_book', 'tufte_html_book')) {
1123
unlink('_book', recursive = TRUE)
1224
file.copy('index.Rmd', '_index.Rmd')
25+
file.copy('_output.yml', '_output.yml2')
1326
writeLines(
1427
gsub('^title: ".*"', s[i], gsub('gitbook', fmt, x)), 'index.Rmd'
1528
)
29+
cat(
30+
'bookdown::', fmt, ':\n', ' css: [style.css, toc.css]\n', sep = '', file = '_output.yml',
31+
append = TRUE
32+
)
1633
cmd = sprintf("bookdown::render_book('index.Rmd', 'bookdown::%s', quiet = TRUE)", fmt)
1734
res = bookdown:::Rscript(c('-e', shQuote(cmd)))
1835
file.rename('_index.Rmd', 'index.Rmd')
36+
file.rename('_output.yml2', '_output.yml')
1937
if (res != 0) stop('Failed to compile the book to ', fmt)
2038
i = i + 1
2139
bookdown::publish_book(paste0('bookdown-demo', i))

_render.R

Lines changed: 0 additions & 14 deletions
This file was deleted.

bookdown-demo.Rproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ LaTeX: pdfLaTeX
1515
AutoAppendNewline: Yes
1616
StripTrailingWhitespace: Yes
1717

18-
BuildType: Makefile
18+
BuildType: Website

index.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ title: "A Minimal Book Example"
33
author: "Yihui Xie"
44
date: "`r Sys.Date()`"
55
knit: "bookdown::render_book"
6-
site: true
6+
site: bookdown::bookdown_site
7+
output: bookdown::gitbook
78
documentclass: book
89
bibliography: [book.bib, packages.bib]
910
biblio-style: apalike

0 commit comments

Comments
 (0)