Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tables in call to action #306

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 1 addition & 1 deletion lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def render_image(image)
extension("call-to-action", surrounded_by("$CTA")) do |body|
<<~BODY
<div class="call-to-action" markdown="1">
#{body.strip}
#{body.strip.gsub(/\A^\|/, "\n|").gsub(/\|$\Z/, "|\n")}
</div>
BODY
end
Expand Down
59 changes: 59 additions & 0 deletions test/govspeak_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,65 @@ class GovspeakTest < Minitest::Test
<p>Here is some text</p>)
end

test_given_govspeak "
$CTA
|Heading 1|Heading 2|
|-|-|
|information|more information|
$CTA" do
assert_html_output %(
<div class="call-to-action">

<table>
<thead>
<tr>
<th scope="col">Heading 1</th>
<th scope="col">Heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>information</td>
<td>more information</td>
</tr>
</tbody>
</table>

</div>)
end

test_given_govspeak "
$CTA

### A heading within the CTA

|Heading 1|Heading 2|
|-|-|
|information|more information|

$CTA" do
assert_html_output %(
<div class="call-to-action">
<h3 id="a-heading-within-the-cta">A heading within the CTA</h3>

<table>
<thead>
<tr>
<th scope="col">Heading 1</th>
<th scope="col">Heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>information</td>
<td>more information</td>
</tr>
</tbody>
</table>

</div>)
end

test_given_govspeak "
Here is some text\n

Expand Down
Loading