govspeak 7.0.2 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/govspeak/html_sanitizer.rb +2 -0
- data/lib/govspeak/post_processor.rb +17 -0
- data/lib/govspeak/version.rb +1 -1
- data/lib/govspeak.rb +1 -1
- data/test/govspeak_table_with_headers_test.rb +10 -10
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3ea39476d15515cff8cf40fa41951ed6d551a495e6f8a40415fdb4eb7752660
|
4
|
+
data.tar.gz: e084cd737b290c2254fd43796ea4c0a99b906790034a22f258d509a556a726a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c732aaee36be6d012574e52e6d7dc07a906a539f19e9e5d6f4bbf793a7936761fdc5f5c1e8cade26da7ed93830044017fea897ef7890a1d226796407166e372a
|
7
|
+
data.tar.gz: b7c8a84a1baa01b04483674f10708dd96467b343560dd3c1465de7a0846870ab7a99a6a63da892b48399e4d9cb30f7f18f28273d1a7ad85d433a8a9b79a49fac
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
## 7.1.0
|
2
|
+
|
3
|
+
* Drop support for Ruby 2.7 [#272](https://github.com/alphagov/govspeak/pull/272)
|
4
|
+
* Replace inline style attributes in td/th elements with classes [#268](https://github.com/alphagov/govspeak/pull/268)
|
5
|
+
|
1
6
|
## 7.0.2
|
2
7
|
|
3
|
-
* Fix for abbreviations nested in button. [#267]
|
8
|
+
* Fix for abbreviations nested in button. [#267](https://github.com/alphagov/govspeak/pull/267)
|
4
9
|
|
5
10
|
## 7.0.1
|
6
11
|
|
@@ -69,6 +69,8 @@ class Govspeak::HtmlSanitizer
|
|
69
69
|
"svg" => Sanitize::Config::RELAXED[:attributes][:all] + %w[xmlns width height viewbox focusable],
|
70
70
|
"path" => Sanitize::Config::RELAXED[:attributes][:all] + %w[fill d],
|
71
71
|
"div" => [:data],
|
72
|
+
# @TODO These style attributes can be removed once we've checked there
|
73
|
+
# isn't hardcoded HTML in documents that uses them
|
72
74
|
"th" => Sanitize::Config::RELAXED[:attributes]["th"] + %w[style],
|
73
75
|
"td" => Sanitize::Config::RELAXED[:attributes]["td"] + %w[style],
|
74
76
|
"govspeak-embed-attachment" => %w[content-id],
|
@@ -102,6 +102,23 @@ module Govspeak
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
extension("convert table cell inline styles to classes") do |document|
|
106
|
+
document.css("th[style], td[style]").each do |el|
|
107
|
+
style = el.remove_attribute("style")
|
108
|
+
matches = style.value.scan(/text-align:\s*(left|center|right)/).flatten
|
109
|
+
|
110
|
+
next unless matches.any?
|
111
|
+
|
112
|
+
class_name = "cell-text-#{matches.last}"
|
113
|
+
|
114
|
+
if el[:class]
|
115
|
+
el[:class] += " #{class_name}"
|
116
|
+
else
|
117
|
+
el[:class] = class_name
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
105
122
|
extension("use gem component for buttons") do |document|
|
106
123
|
document.css(".govuk-button").map do |el|
|
107
124
|
button_html = GovukPublishingComponents.render(
|
data/lib/govspeak/version.rb
CHANGED
data/lib/govspeak.rb
CHANGED
@@ -32,7 +32,7 @@ module Govspeak
|
|
32
32
|
class Document
|
33
33
|
Parser = Kramdown::Parser::Govuk
|
34
34
|
PARSER_CLASS_NAME = Parser.name.split("::").last
|
35
|
-
UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
35
|
+
UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
36
36
|
NEW_PARAGRAPH_LOOKBEHIND = %q{(?<=\A|\n\n|\r\n\r\n)}.freeze
|
37
37
|
|
38
38
|
@extensions = []
|
@@ -58,21 +58,21 @@ class GovspeakTableWithHeadersTest < Minitest::Test
|
|
58
58
|
<table>
|
59
59
|
<thead>
|
60
60
|
<tr>
|
61
|
-
<td
|
62
|
-
<th
|
63
|
-
<th
|
61
|
+
<td class="cell-text-left"></td>
|
62
|
+
<th scope="col" class="cell-text-center">Second Column</th>
|
63
|
+
<th scope="col" class="cell-text-right">Third Column</th>
|
64
64
|
</tr>
|
65
65
|
</thead>
|
66
66
|
<tbody>
|
67
67
|
<tr>
|
68
|
-
<th
|
69
|
-
<td
|
70
|
-
<td
|
68
|
+
<th scope="row" class="cell-text-left">First row</th>
|
69
|
+
<td class="cell-text-center">Cell</td>
|
70
|
+
<td class="cell-text-right">Cell</td>
|
71
71
|
</tr>
|
72
72
|
<tr>
|
73
|
-
<th
|
74
|
-
<td
|
75
|
-
<td
|
73
|
+
<th scope="row" class="cell-text-left">Second row</th>
|
74
|
+
<td class="cell-text-center">Cell</td>
|
75
|
+
<td class="cell-text-right">Cell</td>
|
76
76
|
</tr>
|
77
77
|
</tbody>
|
78
78
|
</table>
|
@@ -255,7 +255,7 @@ class GovspeakTableWithHeadersTest < Minitest::Test
|
|
255
255
|
assert_equal document_body_with_hashes_for_row_headers.to_html, expected_outcome
|
256
256
|
end
|
257
257
|
|
258
|
-
test "Cells are
|
258
|
+
test "Cells are given classes to indicate alignment" do
|
259
259
|
assert_equal document_body_with_alignments.to_html, expected_outcome_for_table_with_alignments
|
260
260
|
end
|
261
261
|
|
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.1.0
|
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: 2023-
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '35.1'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '35.1'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: htmlentities
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +190,14 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - '='
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: 4.
|
193
|
+
version: 4.10.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.10.0
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: simplecov
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -320,36 +320,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
320
320
|
requirements:
|
321
321
|
- - ">="
|
322
322
|
- !ruby/object:Gem::Version
|
323
|
-
version: '
|
323
|
+
version: '3.0'
|
324
324
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
325
325
|
requirements:
|
326
326
|
- - ">="
|
327
327
|
- !ruby/object:Gem::Version
|
328
328
|
version: '0'
|
329
329
|
requirements: []
|
330
|
-
rubygems_version: 3.4.
|
330
|
+
rubygems_version: 3.4.10
|
331
331
|
signing_key:
|
332
332
|
specification_version: 4
|
333
333
|
summary: Markup language for single domain
|
334
334
|
test_files:
|
335
335
|
- test/blockquote_extra_quote_remover_test.rb
|
336
336
|
- test/govspeak_attachment_link_test.rb
|
337
|
-
- test/
|
338
|
-
- test/
|
339
|
-
- test/
|
337
|
+
- test/govspeak_attachment_test.rb
|
338
|
+
- test/govspeak_attachments_image_test.rb
|
339
|
+
- test/govspeak_attachments_inline_test.rb
|
340
340
|
- test/govspeak_button_test.rb
|
341
|
+
- test/govspeak_contacts_test.rb
|
342
|
+
- test/govspeak_extract_contact_content_ids_test.rb
|
343
|
+
- test/govspeak_footnote_test.rb
|
344
|
+
- test/govspeak_images_bang_test.rb
|
345
|
+
- test/govspeak_images_test.rb
|
346
|
+
- test/govspeak_link_extractor_test.rb
|
341
347
|
- test/govspeak_link_test.rb
|
342
|
-
- test/
|
343
|
-
- test/govspeak_test.rb
|
348
|
+
- test/govspeak_structured_headers_test.rb
|
344
349
|
- test/govspeak_table_with_headers_test.rb
|
350
|
+
- test/govspeak_test.rb
|
351
|
+
- test/govspeak_test_helper.rb
|
352
|
+
- test/html_sanitizer_test.rb
|
345
353
|
- test/html_validator_test.rb
|
346
|
-
- test/govspeak_attachments_image_test.rb
|
347
|
-
- test/govspeak_images_bang_test.rb
|
348
|
-
- test/govspeak_link_extractor_test.rb
|
349
354
|
- test/presenters/h_card_presenter_test.rb
|
350
|
-
- test/
|
351
|
-
- test/govspeak_attachment_test.rb
|
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
|
355
|
+
- test/test_helper.rb
|