diff --git a/CHANGELOG.md b/CHANGELOG.md index 05f19fb4..d6519e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased + +* Fix tables within call to action component ([#306](https://github.com/alphagov/govspeak/pull/306)) + ## 8.3.3 * Fix single line formatting of call to action component ([#302](https://github.com/alphagov/govspeak/pull/302)) diff --git a/lib/govspeak.rb b/lib/govspeak.rb index f49d842b..0cd2882c 100644 --- a/lib/govspeak.rb +++ b/lib/govspeak.rb @@ -278,7 +278,7 @@ def render_image(image) extension("call-to-action", surrounded_by("$CTA")) do |body| <<~BODY
- #{body.strip} + #{body.strip.gsub(/\A^\|/, "\n|").gsub(/\|$\Z/, "|\n")}
BODY end diff --git a/test/govspeak_test.rb b/test/govspeak_test.rb index 21788732..f75a751e 100644 --- a/test/govspeak_test.rb +++ b/test/govspeak_test.rb @@ -467,6 +467,65 @@ class GovspeakTest < Minitest::Test

Here is some text

) end + test_given_govspeak " + $CTA + |Heading 1|Heading 2| + |-|-| + |information|more information| + $CTA" do + assert_html_output %( +
+ + + + + + + + + + + + + + +
Heading 1Heading 2
informationmore information
+ +
) + end + + test_given_govspeak " + $CTA + + ### A heading within the CTA + + |Heading 1|Heading 2| + |-|-| + |information|more information| + + $CTA" do + assert_html_output %( +
+

A heading within the CTA

+ + + + + + + + + + + + + + +
Heading 1Heading 2
informationmore information
+ +
) + end + test_given_govspeak " Here is some text\n