Skip to content

Commit

Permalink
Include attachments when parsing numbered lists
Browse files Browse the repository at this point in the history
We currently process numbered lists in a two step process:

1. create the list itself
2. parse each line within the list through govspeak again

In the second step, govspeak has no knowledge of the attachments as we
weren't including this information.

Therefore adding in the attachment data, so govspeak can include these
inline.
  • Loading branch information
brucebolt committed Aug 1, 2023
1 parent baf3f66 commit 068b2bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

* Allow attachment links wtihin numbered lists ([#283](https://github.com/alphagov/govspeak/pull/283))

## 8.0.1

* Add margin-bottom to embedded attachments ([#281](https://github.com/alphagov/govspeak/pull/281))
Expand Down
2 changes: 1 addition & 1 deletion lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def render_image(image)

extension("numbered list", /^[ \t]*((s\d+\.\s.*(?:\n|$))+)/) do |body|
body.gsub!(/s(\d+)\.\s(.*)(?:\n|$)/) do
"<li>#{Govspeak::Document.new(Regexp.last_match(2).strip).to_html}</li>\n"
"<li>#{Govspeak::Document.new(Regexp.last_match(2).strip, attachments: attachments).to_html}</li>\n"
end
%(<ol class="steps">\n#{body}</ol>)
end
Expand Down

0 comments on commit 068b2bc

Please sign in to comment.