Skip to content

Commit

Permalink
remove existing IDs on h2 and assign our own IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Oct 3, 2024
1 parent aa9836f commit f047de1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ pkg_manual = function(name = detect_pkg()) {
close(con)
# extract body, which may end at </main> (R 4.4.x) or </div></body> (R 4.3.x)
txt = gsub('.*?(<h2[ |>].*)(</main>|</div>\\s*</body>).*', '\\1', one_string(txt))
sub('<h2>', sprintf('<h2 id="sec-man-%s">', alnum_id(al[[i]][1])), txt, fixed = TRUE)
txt = gsub('<h2 id="[^"]+"', '<h2', txt) # remove existing ID
sub('<h2', sprintf('<h2 id="sec-man-%s"', alnum_id(al[[i]][1])), txt, fixed = TRUE)
})

# extract all aliases and put them in the beginning (like a TOC)
Expand Down

0 comments on commit f047de1

Please sign in to comment.