Skip to content

Commit

Permalink
Prevent user error when incorrectly formatted footnotes are added to …
Browse files Browse the repository at this point in the history
…HTML attachments

When footnotes are used in HTML attachments, this function would cause an unhelpful user error to be displayed. This will allow the attachment to save.

Example of incorrectly formatted footnotes:

[^22]: CDC. Centre for Disease Control and Prevention. Invasive Mold Infections in Immunocompromised People [updated 06/06/2019]. Available from: Invasive Mold Infections in Immunocompromised People | Mold | CDC
23. David J. Pevalin, Aaron Reeves, Emma Baker, Rebecca Bentley, The impact of persistent poor housing conditions on mental health: A longitudinal population-based study, Preventive Medicine, Volume 105, 2017, Pages 304-310, https://doi.org/10.1016/j.ypmed.2017.09.020

22 contains the character | which triggers table formatting. 23 is not correctly formatted as a footnote.

Co-authored-by: Bruce Bolt <bruce.bolt@digital.cabinet-office.gov.uk>
  • Loading branch information
AshGDS and brucebolt committed Aug 30, 2023
1 parent ee3ffea commit b9199e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

* Prevent user error when incorrectly formatted footnotes are added to HTML attachments ([#287](https://github.com/alphagov/govspeak/pull/287))

## 8.2.0

* Reintroduce support for acronyms in Call To Action blocks and in Legislative Lists ([#285](https://github.com/alphagov/govspeak/pull/285))
Expand Down
2 changes: 2 additions & 0 deletions lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ def encode(text)
end

def add_acronym_alt_text(html)
return unless html

@acronyms.each do |acronym|
html.gsub!(acronym[0], "<abbr title=\"#{acronym[1].strip}\">#{acronym[0]}</abbr>")
end
Expand Down

0 comments on commit b9199e8

Please sign in to comment.