Skip to content

Commit

Permalink
Add support for acronyms in Legislative Lists
Browse files Browse the repository at this point in the history
This code was previously removed as it was considered unreliable as
acronyms within HTML tag attributes were also being replaced.

Adding it back in, but now parsing the acronyms before converting to
HTML.
  • Loading branch information
brucebolt committed Aug 21, 2023
1 parent a0aeaa6 commit 7daa93c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def footnote_definitions(source)
number = footnote[0]
text = footnote[1].strip
footnote_definition = Govspeak::Document.new(text).to_html[/(?<=<p>).*(?=<\/p>)/]
footnote_definition = add_acronym_alt_text(footnote_definition)

<<~HTML_SNIPPET
<li id="fn:#{number}" role="doc-endnote">
Expand All @@ -163,10 +164,6 @@ def footnote_definitions(source)
</div>
HTML_CONTAINER
end

# unless @footnote_definition_html.nil? && @acronyms.size.positive?
# add_acronym_alt_text(@footnote_definition_html)
# end
end

def remove_forbidden_characters(source)
Expand Down Expand Up @@ -358,6 +355,8 @@ def render_image(image)

extension("legislative list", /#{NEW_PARAGRAPH_LOOKBEHIND}\$LegislativeList\s*$(.*?)\$EndLegislativeList/m) do |body|
Govspeak::KramdownOverrides.with_kramdown_ordered_lists_disabled do
body = add_acronym_alt_text(body.strip)

Kramdown::Document.new(body.strip).to_html.tap do |doc|
doc.gsub!("<ul>", "<ol>")
doc.gsub!("</ul>", "</ol>")
Expand All @@ -372,8 +371,6 @@ def render_image(image)

doc.sub!(/(\[\^#{footnote}\])/, html)
end

# add_acronym_alt_text(doc) if @acronyms.size.positive?
end
end
end
Expand Down

0 comments on commit 7daa93c

Please sign in to comment.