-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.R
34 lines (31 loc) · 897 Bytes
/
build.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(bookdown)
build_chapter_hdz <- function(
head, toc, chapter, link_prev, link_next, rmd_cur, html_cur, foot
) {
toc = gsub("^(<li>)(.+<ul>)$", "<li class=\"has-sub\">\\2",
toc)
chapter = gsub("class=\"section ", "class=content \"",
chapter)
chapter = gsub("<h1(.+)?/h1>", "<h1\\1/h1><hr/>",
chapter)
paste(c(
head,
toc,
chapter,
"<p style=\"text-align: center;\">",
bookdown:::source_link(rmd_cur, type = "edit"),
bookdown:::source_link(rmd_cur, type = "history"),
bookdown:::source_link(rmd_cur, type = "view"),
foot),
collapse = "\n")
}
output <- html_book(
split_by = "chapter",
template = bookdown:::bookdown_file("templates/hedaozi_iknow.html"),
page_builder = build_chapter_hdz,
toc_depth = 1
)
rmarkdown::render_site(
output_format = output,
encoding = 'UTF-8'
)