govspeak 7.0.1 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8013e06cbc3f6f61be8953690c30bf05999ee7b405127bf9ab05566021dff5d6
4
- data.tar.gz: d0db3c14af86be0a18662a1aacc9d6f058e0e72295957c478206e41dc97ca06f
3
+ metadata.gz: d3ea39476d15515cff8cf40fa41951ed6d551a495e6f8a40415fdb4eb7752660
4
+ data.tar.gz: e084cd737b290c2254fd43796ea4c0a99b906790034a22f258d509a556a726a8
5
5
  SHA512:
6
- metadata.gz: 07aedd1b981eb39f4b13327cb1192b598fbd0b90a1fc5f0a3c85d05e9baa428022435fe1891cbd576b824f410b5f9daf68b96d0742dfbdc05abcda1b946cdb9d
7
- data.tar.gz: 75f8333f15d52a9e4e358abf8319daf1e05a2800f347937f2b63c52f1d860d691b30b72013ad07e310e2f9926ed63a8b344b5509271a9161a5a307353ea6feaf
6
+ metadata.gz: c732aaee36be6d012574e52e6d7dc07a906a539f19e9e5d6f4bbf793a7936761fdc5f5c1e8cade26da7ed93830044017fea897ef7890a1d226796407166e372a
7
+ data.tar.gz: b7c8a84a1baa01b04483674f10708dd96467b343560dd3c1465de7a0846870ab7a99a6a63da892b48399e4d9cb30f7f18f28273d1a7ad85d433a8a9b79a49fac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
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
+
6
+ ## 7.0.2
7
+
8
+ * Fix for abbreviations nested in button. [#267](https://github.com/alphagov/govspeak/pull/267)
9
+
1
10
  ## 7.0.1
2
11
 
3
12
  * Govspeak was stripping superscript from markdown when it shouldn't have. [#264](https://github.com/alphagov/govspeak/pull/264)
@@ -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,11 +102,28 @@ 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(
108
125
  "govuk_publishing_components/components/button",
109
- text: el.inner_html,
126
+ text: el.inner_html.html_safe,
110
127
  href: el["href"],
111
128
  start: el["data-start"],
112
129
  data_attributes: {
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "7.0.1".freeze
2
+ VERSION = "7.1.0".freeze
3
3
  end
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.freeze
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 = []
@@ -110,4 +110,15 @@ class GovspeakTest < Minitest::Test
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
@@ -58,21 +58,21 @@ class GovspeakTableWithHeadersTest < Minitest::Test
58
58
  <table>
59
59
  <thead>
60
60
  <tr>
61
- <td style="text-align: left"></td>
62
- <th style="text-align: center" scope="col">Second Column</th>
63
- <th style="text-align: right" scope="col">Third Column</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 style="text-align: left" scope="row">First row</th>
69
- <td style="text-align: center">Cell</td>
70
- <td style="text-align: right">Cell</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 style="text-align: left" scope="row">Second row</th>
74
- <td style="text-align: center">Cell</td>
75
- <td style="text-align: right">Cell</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 aligned correctly" do
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.1
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: 2022-12-16 00:00:00.000000000 Z
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: '23'
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: '23'
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.9.0
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.9.0
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: '2.7'
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.3.26
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/govspeak_images_test.rb
338
- - test/test_helper.rb
339
- - test/govspeak_footnote_test.rb
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/html_sanitizer_test.rb
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/govspeak_test_helper.rb
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