Skip to content

Commit

Permalink
Find max data-number for reference section instead of hard coded numb…
Browse files Browse the repository at this point in the history
…er (#247)
  • Loading branch information
e-perl-NOAA authored Aug 16, 2024
1 parent 977f791 commit 02064f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build-ss3-manual-html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,17 @@ jobs:
# Add title to references
where_add <- (grep("references csl-bib-body hanging-indent",
html_txt, fixed = TRUE) - 1)
dat_num <- grep("data-number", html_txt)
dat_num_actual <- html_txt[dat_num]
dat_num_actual <- gsub(".*data-number=", "", dat_num_actual)
ref_num <- max(as.numeric(sub("\\D*(\\d+).*", "\\1", dat_num_actual))) + 1
html_txt <- append(html_txt,
'<h1 data-number="17" id="sec:references"><span class="header-section-number">17</span> References</h1>',
paste0('<h1 data-number="', ref_num, '" id="sec:references"><span class="header-section-number">', ref_num, '</span> References</h1>'),
after = where_add)
# Add references to table of contents
where_add <- grep("</nav>", html_txt, fixed = TRUE)-2
html_txt <- append(html_txt,
'<li><a href="#sec:references"><span class="toc-section-number">17</span> References</a></li>',
paste0('<li><a href="#sec:references"><span class="toc-section-number">', ref_num, '</span> References</a></li>'),
after = where_add)
writeLines(html_txt, "SS330_User_Manual.html")
shell: Rscript {0}
Expand Down

0 comments on commit 02064f6

Please sign in to comment.