Skip to content

Commit

Permalink
Make it so only chapters are collected
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy committed May 16, 2024
1 parent 1073ca6 commit a8a0b81
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/bookdown_to_leanpub.R
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ get_chapters <- function(bookdown_index = file.path("docs", "index.html"),
# Get the sidebar stuff
nodes <- rvest::html_nodes(index_html, xpath = paste0("//", 'div[@class="sidebar-item-container"]'))

# We only want chapters
nodes <- nodes[grep("chapter",as.character(nodes))]

# Extract chapter nodes from the sidebar
chapt_titles <- nodes %>%
rvest::html_nodes('span.chapter-title') %>%
Expand All @@ -453,7 +456,8 @@ get_chapters <- function(bookdown_index = file.path("docs", "index.html"),
rvest::html_nodes('span.chapter-number') %>%
rvest::html_text()

data_path <- rvest::html_nodes(nodes, xpath = paste0("//", 'a[@class="sidebar-item-text sidebar-link"]')) %>%
data_path <- nodes %>%
rvest::html_nodes('a.sidebar-item-text.sidebar-link') %>%
rvest::html_attr('href') %>%
stringr::str_remove("^\\.\\/")

Expand Down

0 comments on commit a8a0b81

Please sign in to comment.