diff --git a/CHANGELOG.md b/CHANGELOG.md index d5e70b83..00e943f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 8.3.1 + +* Bug fixes related to block elements in call to action and legislative list components ([#293](https://github.com/alphagov/govspeak/pull/293)) + ## 8.3.0 * Various bug fixes related to abbreviations in call to action and legislative list components ([#291](https://github.com/alphagov/govspeak/pull/291)) diff --git a/lib/govspeak.rb b/lib/govspeak.rb index 982facb1..a46b5b68 100644 --- a/lib/govspeak.rb +++ b/lib/govspeak.rb @@ -278,9 +278,7 @@ def render_image(image) extension("call-to-action", surrounded_by("$CTA")) do |body| <<~BODY - {::options parse_block_html=\"true\" /} -
#{body}
- {::options parse_block_html=\"false\" /} +
#{body}
BODY end @@ -303,9 +301,9 @@ def render_image(image) # The surrounding div is neccessary to control flow in `parse_block_html` and # maintain the same functionality as a previous version of this extension. <<~BODY - {::options parse_block_html=\"true\" ordered_lists_disabled=\"true\" /} -
#{body}
- {::options parse_block_html=\"false\" ordered_lists_disabled=\"false\" /} + {::options ordered_lists_disabled=\"true\" /} +
#{body}
+ {::options ordered_lists_disabled=\"false\" /} BODY end diff --git a/test/govspeak_images_test.rb b/test/govspeak_images_test.rb index 498f4519..0d8e132c 100644 --- a/test/govspeak_images_test.rb +++ b/test/govspeak_images_test.rb @@ -4,13 +4,6 @@ class GovspeakImagesTest < Minitest::Test include GovspeakTestHelper - def build_image(attrs = {}) - attrs[:alt_text] ||= "my alt" - attrs[:url] ||= "http://example.com/image.jpg" - attrs[:id] ||= "image-id" - attrs - end - test "Image:image-id syntax renders an image in options[:images]" do given_govspeak "[Image:image-id]", images: [build_image] do assert_html_output( diff --git a/test/govspeak_test.rb b/test/govspeak_test.rb index 7accde6c..ae50516e 100644 --- a/test/govspeak_test.rb +++ b/test/govspeak_test.rb @@ -683,6 +683,24 @@ class GovspeakTest < Minitest::Test ) end + test "CTA with image" do + given_govspeak " + $CTA + [Image:image-id] + $CTA + + Some text + ", images: [build_image] do + assert_html_output %( +
+
my alt
+
+ +

Some text

+ ) + end + end + test_given_govspeak " 1. rod 2. jane @@ -1268,6 +1286,24 @@ class GovspeakTest < Minitest::Test ) end + test "LegislativeList with image" do + given_govspeak " + $LegislativeList + [Image:image-id] + $EndLegislativeList + + Some text + ", images: [build_image] do + assert_html_output %( +
+
my alt
+
+ +

Some text

+ ) + end + end + test_given_govspeak " Zippy, Bungle and George did not qualify for the tax exemption in s428. They filled in their tax return accordingly. " do diff --git a/test/govspeak_test_helper.rb b/test/govspeak_test_helper.rb index 4e3c1ec3..5dc3cdfe 100644 --- a/test/govspeak_test_helper.rb +++ b/test/govspeak_test_helper.rb @@ -73,6 +73,13 @@ def deobfuscate_mailto(html) coder.decode(html) end + def build_image(attrs = {}) + attrs[:alt_text] ||= "my alt" + attrs[:url] ||= "http://example.com/image.jpg" + attrs[:id] ||= "image-id" + attrs + end + module ClassMethods def test_given_govspeak(govspeak, options = {}, &block) test "Given #{govspeak}" do