govspeak 7.0.0 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/README.md +6 -1
- data/lib/govspeak/post_processor.rb +9 -9
- data/lib/govspeak/version.rb +1 -1
- data/test/govspeak_button_test.rb +22 -11
- data/test/govspeak_table_with_headers_test.rb +32 -0
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14fa86649f2bb73e47685e2fb16ae978b1dff2a3f7bef496fd7520186547d854
|
4
|
+
data.tar.gz: 203651a48459e58f8974a4621ba3ea0651133077c79b94d0cbf489df8049ceae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f9af0743b85af02263ece3934eb4b8df41b25f1dad626bfd65216dd405110b66c08bf32cbcf1c44a93a0678d8934131e37ec0ca66e37148516d9e3e3ca25ff2
|
7
|
+
data.tar.gz: 175745b808a77d6d7a60b85b617b1df9596c5c2483d0fac784c1d8c42a2eaea71ee2dc7ffdd0f5968417126b97fea0a1583c70598793795da08bd821fa7b1c21
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 7.0.2
|
2
|
+
|
3
|
+
* Fix for abbreviations nested in button. [#267] (https://github.com/alphagov/govspeak/pull/267)
|
4
|
+
|
5
|
+
## 7.0.1
|
6
|
+
|
7
|
+
* Govspeak was stripping superscript from markdown when it shouldn't have. [#264](https://github.com/alphagov/govspeak/pull/264)
|
8
|
+
|
1
9
|
## 7.0.0
|
2
10
|
|
3
11
|
* BREAKING CHANGE Remove `PriorityList`, the `PrimaryList` JS module to render the priority list on the frontend is to be removed [#249](https://github.com/alphagov/govspeak/pull/249)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -669,4 +669,9 @@ which outputs
|
|
669
669
|
Start Now
|
670
670
|
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" role="presentation" focusable="false"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg>
|
671
671
|
</a>
|
672
|
-
```
|
672
|
+
```
|
673
|
+
|
674
|
+
## Licence
|
675
|
+
|
676
|
+
[MIT License](LICENCE)
|
677
|
+
|
@@ -85,20 +85,20 @@ module Govspeak
|
|
85
85
|
|
86
86
|
extension("Add table headers and row / column scopes") do |document|
|
87
87
|
document.css("thead th").map do |el|
|
88
|
-
el.
|
89
|
-
el.
|
90
|
-
el.name = "td" if el.
|
91
|
-
el[:scope] = "col" if el.
|
88
|
+
el.inner_html = el.inner_html.gsub(/^# /, "")
|
89
|
+
el.inner_html = el.inner_html.gsub(/[[:space:]]/, "") if el.inner_html.blank? # Removes a strange whitespace in the cell if the cell is already blank.
|
90
|
+
el.name = "td" if el.inner_html.blank? # This prevents a `th` with nothing inside it; a `td` is preferable.
|
91
|
+
el[:scope] = "col" if el.inner_html.present? # `scope` shouldn't be used if there's nothing in the table heading.
|
92
92
|
end
|
93
93
|
|
94
94
|
document.css(":not(thead) tr td:first-child").map do |el|
|
95
|
-
next unless el.
|
95
|
+
next unless el.inner_html.match?(/^#($|\s.*$)/)
|
96
96
|
|
97
97
|
# Replace '# ' and '#', but not '#Word'.
|
98
98
|
# This runs on the first child of the element to preserve any links
|
99
99
|
el.children.first.content = el.children.first.content.gsub(/^#($|\s)/, "")
|
100
|
-
el.name = "th" if el.
|
101
|
-
el[:scope] = "row" if el.
|
100
|
+
el.name = "th" if el.inner_html.present? # This also prevents a `th` with nothing inside it; a `td` is preferable.
|
101
|
+
el[:scope] = "row" if el.inner_html.present? # `scope` shouldn't be used if there's nothing in the table heading.
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -106,7 +106,7 @@ module Govspeak
|
|
106
106
|
document.css(".govuk-button").map do |el|
|
107
107
|
button_html = GovukPublishingComponents.render(
|
108
108
|
"govuk_publishing_components/components/button",
|
109
|
-
text: el.
|
109
|
+
text: el.inner_html.html_safe,
|
110
110
|
href: el["href"],
|
111
111
|
start: el["data-start"],
|
112
112
|
data_attributes: {
|
@@ -123,7 +123,7 @@ module Govspeak
|
|
123
123
|
extension("use custom footnotes") do |document|
|
124
124
|
document.css("a.footnote").map do |el|
|
125
125
|
footnote_number = el[:href].gsub(/\D/, "")
|
126
|
-
el.
|
126
|
+
el.inner_html = "[footnote #{footnote_number}]"
|
127
127
|
end
|
128
128
|
document.css("[role='doc-backlink']").map do |el|
|
129
129
|
backlink_number = " #{el.css('sup')[0].content}" if el.css("sup")[0].present?
|
data/lib/govspeak/version.rb
CHANGED
@@ -7,18 +7,18 @@ class GovspeakTest < Minitest::Test
|
|
7
7
|
include GovspeakTestHelper
|
8
8
|
|
9
9
|
test_given_govspeak "{button start cross-domain-tracking:UA-23066786-5}[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
10
|
-
assert_html_selector 'a.gem-c-button.govuk-button--start[data-module="cross-domain-tracking"][data-tracking-code="UA-23066786-5"][href="https://www.registertovote.service.gov.uk/register-to-vote/start"]'
|
10
|
+
assert_html_selector 'a.gem-c-button.govuk-button--start[data-module="govuk-button cross-domain-tracking"][data-tracking-code="UA-23066786-5"][href="https://www.registertovote.service.gov.uk/register-to-vote/start"]'
|
11
11
|
assert_text_output "Start now"
|
12
12
|
end
|
13
13
|
|
14
14
|
# The same as above but with line breaks
|
15
15
|
test_given_govspeak "{button start cross-domain-tracking:UA-23066786-5}\n\n\n[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start)\n\n\n{/button}" do
|
16
|
-
assert_html_selector 'a.gem-c-button.govuk-button--start[data-module="cross-domain-tracking"][data-tracking-code="UA-23066786-5"][href="https://www.registertovote.service.gov.uk/register-to-vote/start"]'
|
16
|
+
assert_html_selector 'a.gem-c-button.govuk-button--start[data-module="govuk-button cross-domain-tracking"][data-tracking-code="UA-23066786-5"][href="https://www.registertovote.service.gov.uk/register-to-vote/start"]'
|
17
17
|
assert_text_output "Start now"
|
18
18
|
end
|
19
19
|
|
20
20
|
test_given_govspeak "{button cross-domain-tracking:UA-23066786-5}[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
21
|
-
assert_html_selector 'a.gem-c-button:not(.govuk-button--start)[data-module="cross-domain-tracking"][data-tracking-code="UA-23066786-5"][href="https://www.registertovote.service.gov.uk/register-to-vote/start"]'
|
21
|
+
assert_html_selector 'a.gem-c-button:not(.govuk-button--start)[data-module="govuk-button cross-domain-tracking"][data-tracking-code="UA-23066786-5"][href="https://www.registertovote.service.gov.uk/register-to-vote/start"]'
|
22
22
|
assert_text_output "Start now"
|
23
23
|
end
|
24
24
|
|
@@ -47,7 +47,7 @@ class GovspeakTest < Minitest::Test
|
|
47
47
|
assert_html_output %(
|
48
48
|
<p>Text before the button with line breaks</p>
|
49
49
|
|
50
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="http://www.gov.uk">Start Now</a></p>
|
50
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="http://www.gov.uk">Start Now</a></p>
|
51
51
|
|
52
52
|
<p>test after the button</p>
|
53
53
|
)
|
@@ -65,21 +65,21 @@ class GovspeakTest < Minitest::Test
|
|
65
65
|
# Make sure button renders when typical linebreaks are before it, seen in publishing applications
|
66
66
|
test_given_govspeak "{button}[Line breaks](https://gov.uk/random){/button}\r\n\r\n{button}[Continue](https://gov.uk/random){/button}\r\n\r\n{button}[Continue](https://gov.uk/random){/button}" do
|
67
67
|
assert_html_output %(
|
68
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Line breaks</a></p>
|
68
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="https://gov.uk/random">Line breaks</a></p>
|
69
69
|
|
70
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
70
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
71
71
|
|
72
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
72
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
73
73
|
)
|
74
74
|
end
|
75
75
|
|
76
76
|
test_given_govspeak "{button}[More line breaks](https://gov.uk/random){/button}\n\n{button}[Continue](https://gov.uk/random){/button}\n\n{button}[Continue](https://gov.uk/random){/button}" do
|
77
77
|
assert_html_output %(
|
78
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">More line breaks</a></p>
|
78
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="https://gov.uk/random">More line breaks</a></p>
|
79
79
|
|
80
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
80
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
81
81
|
|
82
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
82
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="https://gov.uk/random">Continue</a></p>
|
83
83
|
)
|
84
84
|
end
|
85
85
|
|
@@ -104,10 +104,21 @@ class GovspeakTest < Minitest::Test
|
|
104
104
|
<p>lorem lorem lorem
|
105
105
|
lorem lorem lorem</p>
|
106
106
|
|
107
|
-
<p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Random page</a></p>
|
107
|
+
<p><a class="gem-c-button govuk-button" role="button" data-module="govuk-button" draggable="false" href="https://gov.uk/random">Random page</a></p>
|
108
108
|
|
109
109
|
<p>lorem lorem lorem
|
110
110
|
lorem lorem lorem</p>
|
111
111
|
)
|
112
112
|
end
|
113
|
+
|
114
|
+
test_given_govspeak "
|
115
|
+
{button start}[Start now JSA](https://www.apply-for-new-style-jsa.dwp.gov.uk/?lang=cy){/button}
|
116
|
+
\n\n
|
117
|
+
*[JSA]: Jobseeker's Allowance
|
118
|
+
" do
|
119
|
+
assert_text_output "Start now JSA"
|
120
|
+
assert_html_output %(
|
121
|
+
<p><a class="gem-c-button govuk-button govuk-button--start" role="button" data-module="govuk-button" draggable="false" href="https://www.apply-for-new-style-jsa.dwp.gov.uk/?lang=cy"> Start now <abbr title="Jobseeker's Allowance">JSA</abbr><svg class="govuk-button__start-icon govuk-!-display-none-print" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewbox="0 0 33 40" focusable="false" aria-hidden="true"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg></a></p>
|
122
|
+
)
|
123
|
+
end
|
113
124
|
end
|
@@ -131,6 +131,34 @@ class GovspeakTableWithHeadersTest < Minitest::Test
|
|
131
131
|
)
|
132
132
|
end
|
133
133
|
|
134
|
+
def expected_outcome_for_table_with_table_headers_containing_superscript
|
135
|
+
%(
|
136
|
+
<table>
|
137
|
+
<thead>
|
138
|
+
<tr>
|
139
|
+
<th scope="col">Foo<sup>bar</sup>
|
140
|
+
</th>
|
141
|
+
<th scope="col">Third Column</th>
|
142
|
+
</tr>
|
143
|
+
</thead>
|
144
|
+
<tbody>
|
145
|
+
<tr>
|
146
|
+
<td>Cell</td>
|
147
|
+
<td>Cell</td>
|
148
|
+
</tr>
|
149
|
+
</tbody>
|
150
|
+
</table>
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
def document_body_with_table_headers_containing_superscript
|
155
|
+
@document_body_with_table_headers_containing_superscript ||= Govspeak::Document.new(%(
|
156
|
+
| Foo<sup>bar</sup> | Third Column |
|
157
|
+
| --------------- | ------------------- |
|
158
|
+
| Cell | Cell |
|
159
|
+
))
|
160
|
+
end
|
161
|
+
|
134
162
|
def expected_outcome_for_table_headers_containing_links
|
135
163
|
%(
|
136
164
|
<table>
|
@@ -242,4 +270,8 @@ class GovspeakTableWithHeadersTest < Minitest::Test
|
|
242
270
|
test "Table headers are not blank" do
|
243
271
|
assert_equal document_body_with_blank_table_headers.to_html, expected_outcome_for_table_with_blank_table_headers
|
244
272
|
end
|
273
|
+
|
274
|
+
test "Table header superscript should parse" do
|
275
|
+
assert_equal document_body_with_table_headers_containing_superscript.to_html, expected_outcome_for_table_with_table_headers_containing_superscript
|
276
|
+
end
|
245
277
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govspeak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -190,14 +190,14 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - '='
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: 4.
|
193
|
+
version: 4.9.0
|
194
194
|
type: :development
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - '='
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: 4.
|
200
|
+
version: 4.9.0
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: simplecov
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -327,29 +327,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
327
|
- !ruby/object:Gem::Version
|
328
328
|
version: '0'
|
329
329
|
requirements: []
|
330
|
-
rubygems_version: 3.
|
330
|
+
rubygems_version: 3.4.2
|
331
331
|
signing_key:
|
332
332
|
specification_version: 4
|
333
333
|
summary: Markup language for single domain
|
334
334
|
test_files:
|
335
|
-
- test/govspeak_footnote_test.rb
|
336
|
-
- test/govspeak_attachments_image_test.rb
|
337
|
-
- test/govspeak_button_test.rb
|
338
335
|
- test/blockquote_extra_quote_remover_test.rb
|
336
|
+
- test/govspeak_attachment_link_test.rb
|
337
|
+
- test/govspeak_images_test.rb
|
339
338
|
- test/test_helper.rb
|
340
|
-
- test/
|
339
|
+
- test/govspeak_footnote_test.rb
|
340
|
+
- test/govspeak_button_test.rb
|
341
|
+
- test/govspeak_link_test.rb
|
341
342
|
- test/html_sanitizer_test.rb
|
342
|
-
- test/govspeak_structured_headers_test.rb
|
343
343
|
- test/govspeak_test.rb
|
344
|
-
- test/
|
345
|
-
- test/govspeak_link_test.rb
|
346
|
-
- test/govspeak_contacts_test.rb
|
347
|
-
- test/govspeak_extract_contact_content_ids_test.rb
|
344
|
+
- test/govspeak_table_with_headers_test.rb
|
348
345
|
- test/html_validator_test.rb
|
346
|
+
- test/govspeak_attachments_image_test.rb
|
347
|
+
- test/govspeak_images_bang_test.rb
|
349
348
|
- test/govspeak_link_extractor_test.rb
|
350
|
-
- test/
|
351
|
-
- test/
|
352
|
-
- test/govspeak_attachments_inline_test.rb
|
349
|
+
- test/presenters/h_card_presenter_test.rb
|
350
|
+
- test/govspeak_test_helper.rb
|
353
351
|
- test/govspeak_attachment_test.rb
|
354
|
-
- test/
|
355
|
-
- test/
|
352
|
+
- test/govspeak_structured_headers_test.rb
|
353
|
+
- test/govspeak_attachments_inline_test.rb
|
354
|
+
- test/govspeak_contacts_test.rb
|
355
|
+
- test/govspeak_extract_contact_content_ids_test.rb
|