From 0434781dc5b6d60edf6d776f32837ea2a7e734a7 Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Wed, 31 Jan 2024 11:53:02 +0000 Subject: [PATCH] Fix tables in call to action Tables must have a leading and trailing blank line in markdown. Stripping the body of a call to action means that these are missing and tables do not render as expected. Therefore reinstating the blank line either side of a table contained with a CTA. --- lib/govspeak.rb | 2 +- test/govspeak_test.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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..47ef2679 100644 --- a/test/govspeak_test.rb +++ b/test/govspeak_test.rb @@ -467,6 +467,33 @@ 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 " Here is some text\n