From 9fa468c626e3600b500b476a8f827aa243cce2cb Mon Sep 17 00:00:00 2001 From: Max Harden Date: Thu, 13 May 2021 09:57:21 +0100 Subject: [PATCH 1/2] Switch aside tag for div tag for better semantics --- CHANGELOG.md | 5 +++++ lib/govspeak.rb | 4 ++-- test/govspeak_test.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3200ea..889137f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Unreleased + +* Update failing test [212](https://github.com/alphagov/govspeak/pull/212) +* Fix stats headline HTML semantics [213](https://github.com/alphagov/govspeak/pull/213) + ## 6.7.0 * Update heading & docs [#206](https://github.com/alphagov/govspeak/pull/206) diff --git a/lib/govspeak.rb b/lib/govspeak.rb index f0ded5f5..fb3a4c84 100644 --- a/lib/govspeak.rb +++ b/lib/govspeak.rb @@ -185,8 +185,8 @@ def insert_strong_inside_p(body, parser = Govspeak::Document) end extension("stat-headline", %r${stat-headline}(.*?){/stat-headline}$m) do |body| - %(\n\n\n) + %(\n\n
+#{Govspeak::Document.new(body.strip).to_html}
\n) end # FIXME: these surrounded_by arguments look dodgy diff --git a/test/govspeak_test.rb b/test/govspeak_test.rb index 661c7ed7..eea1e2bd 100644 --- a/test/govspeak_test.rb +++ b/test/govspeak_test.rb @@ -30,7 +30,7 @@ class GovspeakTest < Minitest::Test test "stat-headline block extension" do rendered = Govspeak::Document.new("this \n{stat-headline}*13.8bn* Age of the universe in years{/stat-headline}").to_html - assert_equal %(

this

\n\n\n), rendered + assert_equal %(

this

\n\n
\n

13.8bn Age of the universe in years

\n
\n), rendered end test "extracts headers with text, level and generated id" do From f780bbb947978afaf77cc165bbac27fd7f56f25c Mon Sep 17 00:00:00 2001 From: Max Harden Date: Thu, 13 May 2021 10:35:38 +0100 Subject: [PATCH 2/2] Update to readme to match code --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a8ea2094..307a2b7d 100644 --- a/README.md +++ b/README.md @@ -123,9 +123,9 @@ Statistic headlines highlight important numbers in content. Displays a statistic Creates the following: ```html - + ``` ## Points of Contact