Skip to content

Commit 0e6851d

Browse files
Merge pull request #415 from UBC-DSCI/patch-margins
fixed margin issue in reading
2 parents 94a5b88 + 205ec80 commit 0e6851d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

build_pdf.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Copy files
44
cp references.bib pdf/
55
cp authors.Rmd pdf/
6+
cp foreword-text.Rmd pdf/
67
cp preface-text.Rmd pdf/
78
cp acknowledgements.Rmd pdf/
89
cp intro.Rmd pdf/
@@ -29,6 +30,7 @@ docker run --rm -m 5g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsc
2930
# clean files in pdf dir
3031
rm -rf pdf/references.bib
3132
rm -rf pdf/authors.Rmd
33+
rm -rf pdf/foreword-text.Rmd
3234
rm -rf pdf/preface-text.Rmd
3335
rm -rf pdf/acknowledgements.Rmd
3436
rm -rf pdf/intro.Rmd

reading.Rmd

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ library(magrittr)
66
library(knitr)
77
knitr::opts_chunk$set(message = FALSE,
88
fig.align = "center")
9+
10+
print_html_nodes <- function(html_nodes_object) {
11+
if(!is_latex_output()) {
12+
html_nodes_object
13+
} else {
14+
output <- capture.output(html_nodes_object)
15+
16+
for (i in seq_along(output)) {
17+
if (nchar(output[i]) <= 79) {
18+
cat(output[i], sep = "\n")
19+
} else {
20+
cat(str_sub(output[i], start = 1, end = 79), sep = "\n")
21+
}
22+
}
23+
}
24+
}
925
```
1026

1127
## Overview
@@ -1056,7 +1072,7 @@ having one very long line of code with the string
10561072
`"td:nth-child(5),td:nth-child(7),.infobox:nth-child(122) td:nth-child(1),.infobox td:nth-child(3)"`
10571073
as the second argument of `html_nodes`:
10581074
1059-
```{r 01-select-nodes}
1075+
```{r 01-select-nodes, results = 'hide', echo = TRUE}
10601076
selectors <- paste("td:nth-child(5)",
10611077
"td:nth-child(7)",
10621078
".infobox:nth-child(122) td:nth-child(1)",
@@ -1066,6 +1082,10 @@ population_nodes <- html_nodes(page, selectors)
10661082
head(population_nodes)
10671083
```
10681084
1085+
```{r echo = FALSE}
1086+
print_html_nodes(head(population_nodes))
1087+
```
1088+
10691089
Next we extract the meaningful data&mdash;in other words, we get rid of the HTML code syntax and tags&mdash;from
10701090
the nodes using the `html_text`
10711091
function. In the case of the example

0 commit comments

Comments
 (0)