Skip to content

Commit

Permalink
filter now fixes setup and instructor notes links
Browse files Browse the repository at this point in the history
This addresses #57, #49, and #46
  • Loading branch information
zkamvar committed Apr 13, 2023
1 parent 236c3df commit 727bfd2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,28 @@ fix_all_links <- function(episode) {
fix_internal_slash_links(links)
# make sure links out (e.g. to data via the raw directive are relative)
fix_actually_internal_links(links, episode$lesson)

# rerun to re-parse links
links <- episode$validate_links(warn = FALSE)
rename_local_links(links, from = "setup.html", to = "learners/setup.md")
rename_local_links(links, from = "guide.html", to = "instructors/instructor-notes.md")
invisible(episode)
}

rename_local_links <- function(links, from = "setup.html", to = "learners/setup.md") {
needs_fixing <- links$server == "" &
links$scheme == "" &
links$path == from
nodes <- links$node[needs_fixing]
# loop through the nodes and fix.
purrr::map(nodes, \(x) {
dest <- xml2::xml_attr(x, "destination")
new <- sub(from , to, dest, fixed = TRUE)
xml2::xml_set_attr(x, "destination", new)
})
invisible(links)
}

# Fix all links that are http and not https because that's just kind of an annoying
# thing to have to fix manually when we know what the solution is.
fix_https_links <- function(links) {
Expand Down

0 comments on commit 727bfd2

Please sign in to comment.