From e8aa7b6d40da1c68a18e4a81cbfa48a49a488c39 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Mon, 16 Feb 2026 10:15:09 -0500 Subject: [PATCH 1/3] Update a11y guide with info about how to escape special characters in alt text/captions csv --- vignettes/accessibility_guide.Rmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vignettes/accessibility_guide.Rmd b/vignettes/accessibility_guide.Rmd index 592d5f1a..ffe5a9cf 100644 --- a/vignettes/accessibility_guide.Rmd +++ b/vignettes/accessibility_guide.Rmd @@ -185,6 +185,8 @@ recruitment_alt_text <- new_alt_text 3. As stated earlier, if you see text that looks like a placeholder (e.g., "The x axis, showing the year, spans from B.start.year to B.end.year..."), that means that there was at least one instance where our tool failed to extract a specific value from the model results and substitute it into the placeholder. Please make sure that your alt text and captions contain the expected values before moving forward with your report. Check out the inst/resources/captions_alt_text_template.csv file in the `stockplotr` package to view the template with placeholders. The same package's `write_captions()` function shows how values are extracted from the model results and substituted into the placeholders. +4. If you add a special character (e.g., percentage sign (%) or dollar sign ($); see [full list on this wiki page](https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols)), please add two backslashes before the character to avoid issues compiling your report later on (specifically, the conversion from Quarto to LaTeX via Pandoc, and then compilation of the LaTeX report after running `add_accessibility()` or `add_alttext()`). For example, "The 95% CI" would be written as "The 95\\\\% CI". + ### More resources Looking for more resources for writing alt text? Check out the [NOAA Library's website for creating accessible documents](https://library.noaa.gov/Section508/CreatingDocs). From a6e60f261a541fe2a094bfe587a6e4d06fbd33f8 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Mon, 16 Feb 2026 10:19:33 -0500 Subject: [PATCH 2/3] Update readme example create_template() arg from 'author' to 'authors' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5877e2ec..4917d24e 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ asar::create_template( species = "Petrale sole", spp_latin = "Eopsetta jordani", year = 2023, - author = c("Ian G. Taylor"="NWFSC", "Vladlena Gertseva"="NWFSC", "Nick Tolimieri"="NWFSC"), + authors = c("Ian G. Taylor"="NWFSC", "Vladlena Gertseva"="NWFSC", "Nick Tolimieri"="NWFSC"), include_affiliation = TRUE, simple_affiliation = FALSE, param_names = c("nf","sf"), From be2b74f020b077a0cb8e84d8ce3d00a408261535 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 5 Mar 2026 10:25:00 -0500 Subject: [PATCH 3/3] Update SAFE template table structure from flextable to asar as per https://github.com/nmfs-ost/asar/issues/428 --- inst/templates/safe/01c_plan-team.qmd | 132 +++++++++++++------------- inst/templates/safe/05_data.qmd | 15 ++- 2 files changed, 70 insertions(+), 77 deletions(-) diff --git a/inst/templates/safe/01c_plan-team.qmd b/inst/templates/safe/01c_plan-team.qmd index fead1e20..d1af6b2b 100644 --- a/inst/templates/safe/01c_plan-team.qmd +++ b/inst/templates/safe/01c_plan-team.qmd @@ -5,29 +5,33 @@ ```{r} #| eval: false #| echo: false +# install.packages("devtools") +# devtools::install_github("BenWilliams-NOAA/safe") + +year <- format(Sys.time(), "%Y") + ptdata <- safe::ptdata -flextable::font( - flextable::footnote(flextable::flextable(ptdata), - j = 3, part = "header", ref_symbols = "1", - value = flextable::as_paragraph("Total biomass (age 4+) estimates from age-structured model.") - ), - fontname = "Times New Roman", - part = "all" -) %>% - flextable::footnote( - i = 2, j = 7, part = "body", ref_symbols = "2", - value = flextable::as_paragraph( - flextable::as_chunk(paste0(paste0("Current as of ", date, " . Source: NMFS Alaska Regional Office Catch Accounting System -via the AKFIN database (http://www.akfin.org)."))) - ) - ) %>% - flextable::set_formatter(Year = function(x) sprintf("%s", x)) %>% - flextable::merge_at(i = 1:4, j = 1) %>% - flextable::hrule(rule = "exact") %>% - flextable::hline_top(part = "all") %>% - flextable::hline_bottom() %>% - flextable::fix_border_issues() +ptdata |> + gt::gt() |> + gt::tab_footnote( + footnote = "Total biomass (age 4+) estimates from age-structured model.", + locations = gt::cells_column_labels(columns = Biomass) + ) |> + gt::tab_footnote( + footnote = paste0("Current as of ", year, ". Source: NMFS Alaska Regional Office Catch Accounting System +via the AKFIN database (http://www.akfin.org)."), + locations = cells_column_labels(columns = Catch) + ) |> + gt::fmt_integer(columns = Year, sep_mark = "") |> + gt::fmt_integer(columns = Biomass:Catch, sep_mark = ",") |> + gt::tab_options( + column_labels.font.weight = "bold", + table_body.hlines.style = "none" + ) |> + gt::sub_missing( + missing_text = "" + ) ``` {{< pagebreak >}} @@ -37,51 +41,43 @@ via the AKFIN database (http://www.akfin.org)."))) #| echo: false ptdata2 <- safe::ptdata2 -flextable::font( - flextable::footnote(flextable::flextable(ptdata2[-1, ]), - j = 6, part = "header", ref_symbols = "2", - value = flextable::as_paragraph(flextable::as_chunk( - paste0(paste0( - "Current as of ", date, - " . Source: NMFS Alaska Regional Office Catch Accounting System -via the AKFIN database (http://www.akfin.org)." - )) - )) - ), - fontname = "Times New Roman", - part = "all" -) %>% - flextable::add_header(values = ptdata2[1, ]) %>% - flextable::border_remove() %>% - flextable::merge_at(j = 1) %>% - flextable::compose( - i = 1, j = 3:6, - value = flextable::as_paragraph(as.character(year - 1)), - part = "header" - ) %>% - flextable::compose( - i = 1, j = 7:8, - value = flextable::as_paragraph(as.character(year)), - part = "header" - ) %>% - flextable::compose( - i = 1, j = 9:10, - value = flextable::as_paragraph(as.character(year + 1)), - part = "header" - ) %>% - flextable::merge_at(i = 1, j = 3:6, part = "header") %>% - flextable::merge_at(i = 1, j = 7:8, part = "header") %>% - flextable::merge_at(i = 1, j = 9:10, part = "header") %>% - flextable::align(i = 1, part = "header", align = "center") %>% - flextable::compose( - i = 2, j = 7:10, - value = flextable::as_paragraph(rep(c("ABC", "OFL"), 2)), - part = "header" - ) %>% - flextable::hline_top(part = "body") %>% - flextable::hline_top(part = "header") %>% - flextable::vline(j = c(2, 6, 8)) %>% - flextable::hline_bottom(part = "body") %>% - flextable::fix_border_issues(part = "all") %>% - flextable::set_table_properties(width = .5, layout = "autofit") +year <- format(Sys.time(), "%Y") +date <- Sys.Date() + +yr_prev <- ptdata2[1, 3] # "2021" +yr_curr <- ptdata2[1, 7] # "2022" +yr_next <- ptdata2[1, 9] # "2023" + +ptdata2[-1, ] |> + gt::gt() |> + gt::tab_options( + column_labels.font.weight = "bold", + table_body.hlines.style = "none" + ) |> + gt::cols_label( + OFL = paste(yr_prev, "OFL"), + ABC = paste(yr_prev, "ABC"), + TAC = paste(yr_prev, "TAC"), + Catch = paste(yr_prev, "Catch"), + OFL.1 = paste(yr_curr, "ABC"), + ABC.1 = paste(yr_curr, "OFL"), + OFL.2 = paste(yr_next, "ABC"), + ABC.2 = paste(yr_next, "OFL") + ) |> + gt::tab_footnote( + footnote = paste0("Current as of ", date, ". Source: NMFS Alaska Regional Office Catch Accounting System via the AKFIN database (http://www.akfin.org)."), + locations = cells_column_labels(columns = 6) + ) |> + gt::fmt_integer() |> + gt::cols_align(align = "center", columns = 3:10) |> + gt::cols_align(align = "left", columns = 1:2) |> + gt::sub_missing( + missing_text = "" + ) |> + gt::tab_style( + style = cell_borders(sides = "right", color = "mediumgrey", weight = px(2)), + locations = list( + cells_body(columns = c(6, 8)), + cells_column_labels(columns = c(6, 8)) + ) ) ``` diff --git a/inst/templates/safe/05_data.qmd b/inst/templates/safe/05_data.qmd index ebbcd6bd..7ca3c533 100644 --- a/inst/templates/safe/05_data.qmd +++ b/inst/templates/safe/05_data.qmd @@ -32,15 +32,12 @@ data.frame( "1991-1997, 2003, 2007, 2009, 2011, 2013, 2015, 2017, 2019" ) ) |> - flextable::flextable() |> - flextable::width(j = ~Source, width = 1) |> - flextable::width(j = ~Data, width = 1.5) |> - flextable::width(j = ~Years, width = 4) |> - flextable::merge_v(j = 1) |> - flextable::font(fontname = "Times", part = "all") |> - flextable::fontsize(size = 10) |> - flextable::theme_vanilla() |> - flextable::fix_border_issues() + gt::gt() |> + gt::cols_width( + Source ~ px(100), + Data ~ px(150), + Years ~ px(400) + ) ``` ## Fishery