govspeak 8.3.4 → 8.4.1

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: 474078f8179d567c75b47f781c5d567072a6889a79554fefb81172316828f5fc
4
- data.tar.gz: aa5a44c15285543a1749b3cf129c66eeea2cb6b58d0b98c9970bc5130320c8fb
3
+ metadata.gz: 1fee9ba67d010cc01d04d929c4995d48be18802a9cc263eb766e4fb5dd64ea04
4
+ data.tar.gz: 62206016e1f736157da903662d696438da0406e497d53c6dc0a2574a0cc3555c
5
5
  SHA512:
6
- metadata.gz: 210b4b75330ff66604483b61e0c2f5c78292ab7e3a957839af6f4fb7e5123b8649366945b01a4a03841f0924166475e28751e4e2531cfe10a125ba506b3f9ec6
7
- data.tar.gz: 5c164df64fa4ba9c0bdba31d55644550267543e2549e764cab614db0bf2a2e07cd602d571c51ecad4ec9f402e0d76be5052cb21195616be98aba8c99a843d3c7
6
+ metadata.gz: 3aacba8ee80a9e26f59042d100d74611aef458e90fcdd9b0f5070eb780f25b19a7c28d549ad147afe0af66c802394b134430d5a0d568c2bfd051ef4e2b3582b2
7
+ data.tar.gz: 1fd96e90cb895b1e48f5b678ea63258ac092058aadaff415400785be8ed2654b8dda08975e70e9e7beba8ff5d2bd564d90cca41331e3f00b6d0d0803b8e25140
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 8.4.1
2
+ * Do not pin version of govuk_publishing_components
3
+
4
+ ## 8.4.0
5
+
6
+ * Drop support for Ruby 3.0. The minimum required Ruby version is now 3.1.4.
7
+ * Add support for Ruby 3.3.
8
+ * Allow acronyms within example blocks.
9
+ * Allow tables within example blocks.
10
+ * Allow acronyms within address blocks.
11
+
1
12
  ## 8.3.4
2
13
 
3
14
  * Fix tables within call to action component ([#306](https://github.com/alphagov/govspeak/pull/306))
data/README.md CHANGED
@@ -28,7 +28,7 @@ Once govspeak has been updated and version incremented then:
28
28
 
29
29
  Also, consider if:
30
30
  - [whitehall](https://github.com/alphagov/whitehall) needs updating (as custom govspeak changes are present)
31
- - [govpspeak-preview](https://github.com/alphagov/govspeak-preview) needs updating
31
+ - [govspeak-preview](https://github.com/alphagov/govspeak-preview) needs updating
32
32
 
33
33
  Any pages that use govspeak to generate Content will need to *republished* in order for the new changes to be reflected.
34
34
 
@@ -34,8 +34,8 @@ class Govspeak::HtmlSanitizer
34
34
  # currently does – i.e. to return Sanitize config without any transformers.
35
35
  # e.g. https://github.com/alphagov/hmrc-manuals-api/blob/4a83f78d0bb839520155623fd9b63b3b12a3b13a/app/validators/no_dangerous_html_in_text_fields_validator.rb#L44
36
36
  config_with_transformers = Sanitize::Config.merge(
37
- sanitize_config(allowed_elements: allowed_elements),
38
- transformers: transformers,
37
+ sanitize_config(allowed_elements:),
38
+ transformers:,
39
39
  )
40
40
 
41
41
  Sanitize.clean(@dirty_html, config_with_transformers)
@@ -48,7 +48,7 @@ class Govspeak::HtmlSanitizer
48
48
 
49
49
  Sanitize::Config.merge(
50
50
  Sanitize::Config::RELAXED,
51
- elements: elements,
51
+ elements:,
52
52
  attributes: {
53
53
  # We purposefully disable style attributes which Sanitize::Config::RELAXED allows
54
54
  :all => Sanitize::Config::RELAXED[:attributes][:all] + %w[role aria-label] - %w[style],
@@ -26,7 +26,7 @@ private
26
26
  def govspeak_to_html(sanitize:)
27
27
  Govspeak::Document.new(
28
28
  govspeak_string,
29
- sanitize: sanitize,
29
+ sanitize:,
30
30
  allowed_image_hosts: @allowed_image_hosts,
31
31
  ).to_html
32
32
  end
@@ -67,7 +67,7 @@ module Govspeak
67
67
 
68
68
  attachment_html = GovukPublishingComponents.render(
69
69
  "govuk_publishing_components/components/attachment",
70
- attachment: attachment,
70
+ attachment:,
71
71
  margin_bottom: 6,
72
72
  locale: govspeak_document.locale,
73
73
  )
@@ -86,7 +86,7 @@ module Govspeak
86
86
 
87
87
  attachment_html = GovukPublishingComponents.render(
88
88
  "govuk_publishing_components/components/attachment_link",
89
- attachment: attachment,
89
+ attachment:,
90
90
  locale: govspeak_document.locale,
91
91
  )
92
92
  el.swap(attachment_html)
@@ -51,7 +51,7 @@ module Govspeak
51
51
  MS_POWERPOINT_PRESENTATION_HUMANIZED_CONTENT_TYPE = "MS Powerpoint Presentation".freeze
52
52
 
53
53
  def file_abbr_tag(abbr, title)
54
- content_tag(:abbr, abbr, title: title)
54
+ content_tag(:abbr, abbr, title:)
55
55
  end
56
56
 
57
57
  def humanized_content_type(file_extension)
@@ -34,7 +34,7 @@ module Govspeak
34
34
  lines = []
35
35
  lines << "<figcaption>"
36
36
  lines << %(<p>#{caption}</p>) if caption.present?
37
- lines << %(<p>#{I18n.t('govspeak.image.figure.credit', credit: credit)}</p>) if credit.present?
37
+ lines << %(<p>#{I18n.t('govspeak.image.figure.credit', credit:)}</p>) if credit.present?
38
38
  lines << "</figcaption>"
39
39
  lines.join
40
40
  end
@@ -17,7 +17,7 @@ module Govspeak
17
17
  def t(*args)
18
18
  options = args.last.is_a?(Hash) ? args.last.dup : {}
19
19
  key = args.shift
20
- I18n.t!(key, **options.merge(locale: locale))
20
+ I18n.t!(key, **options.merge(locale:))
21
21
  end
22
22
 
23
23
  def format_with_html_line_breaks(string)
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "8.3.4".freeze
2
+ VERSION = "8.4.1".freeze
3
3
  end
data/lib/govspeak.rb CHANGED
@@ -98,7 +98,7 @@ module Govspeak
98
98
  end
99
99
 
100
100
  def extracted_links(website_root: nil)
101
- Govspeak::LinkExtractor.new(self, website_root: website_root).call
101
+ Govspeak::LinkExtractor.new(self, website_root:).call
102
102
  end
103
103
 
104
104
  def extract_contact_content_ids
@@ -292,10 +292,17 @@ module Govspeak
292
292
  wrap_with_div("place", "$P", Govspeak::Document)
293
293
  wrap_with_div("information", "$I", Govspeak::Document)
294
294
  wrap_with_div("additional-information", "$AI")
295
- wrap_with_div("example", "$E", Govspeak::Document)
295
+
296
+ extension("example", surrounded_by("$E")) do |body|
297
+ <<~BODY
298
+ <div class="example" markdown="1">
299
+ #{body.strip.gsub(/\A^\|/, "\n|").gsub(/\|$\Z/, "|\n")}
300
+ </div>
301
+ BODY
302
+ end
296
303
 
297
304
  extension("address", surrounded_by("$A")) do |body|
298
- %(\n<div class="address"><div class="adr org fn"><p>\n#{body.sub("\n", '').gsub("\n", '<br />')}\n</p></div></div>\n)
305
+ %(\n<div class="address"><div class="adr org fn"><p markdown="1">\n#{body.sub("\n", '').gsub("\n", '<br />')}\n</p></div></div>\n)
299
306
  end
300
307
 
301
308
  extension("legislative list", /#{NEW_PARAGRAPH_LOOKBEHIND}\$LegislativeList\s*$(.*?)\$EndLegislativeList/m) do |body|
@@ -310,7 +317,7 @@ module Govspeak
310
317
 
311
318
  extension("numbered list", /^[ \t]*((s\d+\.\s.*(?:\n|$))+)/) do |body|
312
319
  body.gsub!(/s(\d+)\.\s(.*)(?:\n|$)/) do
313
- "<li>#{Govspeak::Document.new(Regexp.last_match(2).strip, attachments: attachments).to_html}</li>\n"
320
+ "<li>#{Govspeak::Document.new(Regexp.last_match(2).strip, attachments:).to_html}</li>\n"
314
321
  end
315
322
  %(<ol class="steps">\n#{body}</ol>)
316
323
  end
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  class GovspeakAttachmentLinkTest < Minitest::Test
4
4
  def render_govspeak(govspeak, attachments = [])
5
- Govspeak::Document.new(govspeak, attachments: attachments).to_html
5
+ Govspeak::Document.new(govspeak, attachments:).to_html
6
6
  end
7
7
 
8
8
  test "renders an empty string for attachment link that is not found" do
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  class GovspeakAttachmentTest < Minitest::Test
4
4
  def render_govspeak(govspeak, attachments = [])
5
- Govspeak::Document.new(govspeak, attachments: attachments).to_html
5
+ Govspeak::Document.new(govspeak, attachments:).to_html
6
6
  end
7
7
 
8
8
  test "renders an empty string for attachment link that is not found" do
@@ -11,7 +11,7 @@ class GovspeakAttachmentsImageTest < Minitest::Test
11
11
  end
12
12
 
13
13
  def render_govspeak(govspeak, attachments = [])
14
- Govspeak::Document.new(govspeak, attachments: attachments).to_html
14
+ Govspeak::Document.new(govspeak, attachments:).to_html
15
15
  end
16
16
 
17
17
  def compress_html(html)
@@ -11,7 +11,7 @@ class GovspeakAttachmentsInlineTest < Minitest::Test
11
11
  end
12
12
 
13
13
  def render_govspeak(govspeak, attachments = [])
14
- Govspeak::Document.new(govspeak, attachments: attachments).to_html
14
+ Govspeak::Document.new(govspeak, attachments:).to_html
15
15
  end
16
16
 
17
17
  test "renders an empty string for an inline attachment not found" do
@@ -118,7 +118,7 @@ class GovspeakTest < Minitest::Test
118
118
  " do
119
119
  assert_text_output "Start now JSA"
120
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"><span> Start now <abbr title="Jobseeker's Allowance">JSA</abbr></span><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>
121
+ <p><a class="gem-c-button govuk-button govuk-button--start" role="button" data-module="govuk-button" data-ga4-attributes='{"event_name":"navigation","type":"start button"}' draggable="false" href="https://www.apply-for-new-style-jsa.dwp.gov.uk/?lang=cy"><span> Start now <abbr title="Jobseeker's Allowance">JSA</abbr></span><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
122
  )
123
123
  end
124
124
  end
@@ -393,6 +393,19 @@ Teston
393
393
  assert_text_output "street road"
394
394
  end
395
395
 
396
+ test_given_govspeak "
397
+ $A
398
+ street with ACRONYM
399
+ road
400
+ $A
401
+
402
+ *[ACRONYM]: This is the acronym explanation" do
403
+ assert_html_output %(
404
+ <div class="address"><div class="adr org fn"><p>
405
+ street with <abbr title="This is the acronym explanation">ACRONYM</abbr><br>road<br>
406
+ </p></div></div>)
407
+ end
408
+
396
409
  test_given_govspeak "
397
410
  $P
398
411
  $I
@@ -1247,6 +1260,47 @@ Teston
1247
1260
  )
1248
1261
  end
1249
1262
 
1263
+ test_given_govspeak "
1264
+ $E
1265
+ This is an ACRONYM.
1266
+ $E
1267
+
1268
+ *[ACRONYM]: This is the acronym explanation
1269
+ " do
1270
+ assert_html_output %(
1271
+ <div class="example">
1272
+ <p>This is an <abbr title="This is the acronym explanation">ACRONYM</abbr>.</p>
1273
+ </div>
1274
+ )
1275
+ end
1276
+
1277
+ test_given_govspeak "
1278
+ $E
1279
+ |Heading 1|Heading 2|
1280
+ |-|-|
1281
+ |information|more information|
1282
+ $E" do
1283
+ assert_html_output %(
1284
+ <div class="example">
1285
+
1286
+ <table>
1287
+ <thead>
1288
+ <tr>
1289
+ <th scope="col">Heading 1</th>
1290
+ <th scope="col">Heading 2</th>
1291
+ </tr>
1292
+ </thead>
1293
+ <tbody>
1294
+ <tr>
1295
+ <td>information</td>
1296
+ <td>more information</td>
1297
+ </tr>
1298
+ </tbody>
1299
+ </table>
1300
+
1301
+ </div>)
1302
+ end
1303
+
1250
1304
  test_given_govspeak "
1251
1305
  $LegislativeList
1252
1306
  * 1. Item 1[^1] with an ACRONYM
@@ -55,7 +55,7 @@ module GovspeakTestHelper
55
55
  lines = text.split "\n"
56
56
  digits = Math.log10(lines.size + 2).ceil
57
57
  lines.map
58
- .with_index { |line, i| sprintf("%<number>#{digits}d: %<line>s", number: i + 1, line: line) }
58
+ .with_index { |line, i| sprintf("%<number>#{digits}d: %<line>s", number: i + 1, line:) }
59
59
  .join("\n")
60
60
  end
61
61
  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: 8.3.4
4
+ version: 8.4.1
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: 2024-01-31 00:00:00.000000000 Z
11
+ date: 2024-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '6'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 7.2.2
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 7.2.2
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: addressable
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -33,7 +39,7 @@ dependencies:
33
39
  version: 2.3.8
34
40
  - - "<"
35
41
  - !ruby/object:Gem::Version
36
- version: '3'
42
+ version: 2.8.8
37
43
  type: :runtime
38
44
  prerelease: false
39
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +49,7 @@ dependencies:
43
49
  version: 2.3.8
44
50
  - - "<"
45
51
  - !ruby/object:Gem::Version
46
- version: '3'
52
+ version: 2.8.8
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: govuk_publishing_components
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +85,9 @@ dependencies:
79
85
  - - ">="
80
86
  - !ruby/object:Gem::Version
81
87
  version: '0.7'
88
+ - - "<"
89
+ - !ruby/object:Gem::Version
90
+ version: 1.14.7
82
91
  type: :runtime
83
92
  prerelease: false
84
93
  version_requirements: !ruby/object:Gem::Requirement
@@ -86,6 +95,9 @@ dependencies:
86
95
  - - ">="
87
96
  - !ruby/object:Gem::Version
88
97
  version: '0.7'
98
+ - - "<"
99
+ - !ruby/object:Gem::Version
100
+ version: 1.14.7
89
101
  - !ruby/object:Gem::Dependency
90
102
  name: kramdown
91
103
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +105,9 @@ dependencies:
93
105
  - - ">="
94
106
  - !ruby/object:Gem::Version
95
107
  version: 2.3.1
108
+ - - "<"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.4.1
96
111
  type: :runtime
97
112
  prerelease: false
98
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -100,6 +115,9 @@ dependencies:
100
115
  - - ">="
101
116
  - !ruby/object:Gem::Version
102
117
  version: 2.3.1
118
+ - - "<"
119
+ - !ruby/object:Gem::Version
120
+ version: 2.4.1
103
121
  - !ruby/object:Gem::Dependency
104
122
  name: nokogiri
105
123
  requirement: !ruby/object:Gem::Requirement
@@ -190,14 +208,14 @@ dependencies:
190
208
  requirements:
191
209
  - - '='
192
210
  - !ruby/object:Gem::Version
193
- version: 4.14.0
211
+ version: 5.0.2
194
212
  type: :development
195
213
  prerelease: false
196
214
  version_requirements: !ruby/object:Gem::Requirement
197
215
  requirements:
198
216
  - - '='
199
217
  - !ruby/object:Gem::Version
200
- version: 4.14.0
218
+ version: 5.0.2
201
219
  - !ruby/object:Gem::Dependency
202
220
  name: simplecov
203
221
  requirement: !ruby/object:Gem::Requirement
@@ -319,14 +337,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
319
337
  requirements:
320
338
  - - ">="
321
339
  - !ruby/object:Gem::Version
322
- version: '3.0'
340
+ version: 3.1.4
323
341
  required_rubygems_version: !ruby/object:Gem::Requirement
324
342
  requirements:
325
343
  - - ">="
326
344
  - !ruby/object:Gem::Version
327
345
  version: '0'
328
346
  requirements: []
329
- rubygems_version: 3.5.5
347
+ rubygems_version: 3.5.21
330
348
  signing_key:
331
349
  specification_version: 4
332
350
  summary: Markup language for single domain