Closed tobyhodges closed 1 year ago
I was a bit confused by what this meant, but I think @fnattino gave a good description in https://github.com/carpentries/sandpaper-docs/issues/164, and it's definitely a bug (you would, as the author, expect to be able to link to a subsection of the setup)
I believe this is coming from fix_setup_link()
in R/utils-xml.R
The function replaces any occurance of setup.html
with index.html#setup
, but neglects the fragment (everything after the #
). It could be modified like so:
fix_setup_link <- function(nodes = NULL) {
if (length(nodes) == 0) return(nodes)
links <- xml2::xml_find_all(nodes, ".//a")
hrefs <- xml2::url_parse(xml2::xml_attr(links, "href"))
setup_links <- hrefs$scheme == "" &
hrefs$server == "" &
hrefs$path == "setup.html"
+ section_ids <- hrefs$fragment[setup_links]
+ section_ids[section_ids == ""] <- "setup"
+ replacement <- paste0("index.html#", section_ids)
+ xml2::xml_set_attr(links[setup_links], "href", replacement)
- xml2::xml_set_attr(links[setup_links], "href", "index.html#setup")
invisible(nodes)
}
This has been fixed in https://github.com/carpentries/sandpaper/pull/522 and will be available later today
As discussed in https://github.com/carpentries-incubator/geospatial-python/pull/162, internal links to a specific heading within
learners/setup.md
currently resolve toindex.html#setup
i.e. the top of the setup instructions.It would be nice to be able to link to specific sub-sections of the setup instructions, when an anchor is provided with the link to
setup.md
.