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

Semantics fix #213

Merged
merged 2 commits into from
May 17, 2021
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ Statistic headlines highlight important numbers in content. Displays a statistic
Creates the following:

```html
<aside class="stat-headline">
<div class="stat-headline">
<p><em>13.8bn</em> years since the big bang</p>
</aside>
</div>
```

## Points of Contact
Expand Down
4 changes: 2 additions & 2 deletions lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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<aside class="stat-headline">
#{Govspeak::Document.new(body.strip).to_html}</aside>\n)
%(\n\n<div class="stat-headline">
#{Govspeak::Document.new(body.strip).to_html}</div>\n)
end

# FIXME: these surrounded_by arguments look dodgy
Expand Down
2 changes: 1 addition & 1 deletion test/govspeak_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %(<p>this</p>\n\n<aside class="stat-headline">\n<p><em>13.8bn</em> Age of the universe in years</p>\n</aside>\n), rendered
assert_equal %(<p>this</p>\n\n<div class="stat-headline">\n<p><em>13.8bn</em> Age of the universe in years</p>\n</div>\n), rendered
end

test "extracts headers with text, level and generated id" do
Expand Down