diff --git a/NEWS.md b/NEWS.md index 90ca32227..a5a5bb23f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,7 @@ * pkgdown's deploy_to_branch() now cleans out the website directory by default (`clean = TRUE`). To revert to previous behaviour, call it with `clean = FALSE`. (#1394) * pkgdown now supports local searching. It is enabled by default because no set-up is needed for users to - search pkgdown websites. (#1629) + search pkgdown websites. (#1629, with help from @gustavdelius in #1655) * pkgdown builds a more exhaustive sitemap.xml even for websites built with Bootstrap 3. This might change Algolia results if you use Algolia for search. (#1629) diff --git a/R/utils.r b/R/utils.r index f217cdb34..c3ca9ff82 100644 --- a/R/utils.r +++ b/R/utils.r @@ -265,13 +265,9 @@ remove_useless_parts <- function(links, pkg) { get_section_level <- function(section) { as.numeric( - sub( - "level", "", - regmatches( - xml2::xml_attr(section, "class"), - regexpr("level[1-9]", xml2::xml_attr(section, "class") - ) + gsub( + ".*section level(\\d+).*", '\\1', + xml2::xml_attr(section, "class") ) - ) ) }