govspeak 6.7.5 → 6.8.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: fb4fa452bfd1c6f1cdff6b638f91dfbc9961ea2bd7568f4feadd12fe73772532
4
- data.tar.gz: 925ff3efcbb3b3a9a1aa6e0319e9f5a3ec1540febd0168b8517c5aa884e6e69c
3
+ metadata.gz: 4de0ad0d505ecb467987eb27087a076411a0bd6de2fe535eb058b0550d17d09d
4
+ data.tar.gz: 5b1cba9b7ecc6bc47d1f1646e0dfbb3ff3c2a5cee04a41079c8bb419b0b21610
5
5
  SHA512:
6
- metadata.gz: 574ea02a4f90e336a7c2a3b6642a7c1fe91924e8d71f4c55eb71053875c607c19de73aefbb34218d0cbe563c8e95982baf18ce42860a1002e58008efab20a93e
7
- data.tar.gz: db21f5a85823c27024ff78970ec8d8dab64584910f90fdbed5649516abfbf5110fca8c52c99b978c54db3e060e1c654ac46e0995b87f5b8ab400c9dfa971b756
6
+ metadata.gz: def9659344fe5ed585999686924483c0c8dbc6a130820b86fa427d3eee31b635f2ac64efd0e15a2e42d5102e0b709f15f13c5d70f9d76c90757241bb6734bd23
7
+ data.tar.gz: 6ff2c9ae06337d1b8030cf823c8dab8983a99c0fab7abe7673e7c917347ff91be94834c6b00601397ecef2ada1837e58c69cf21419a872571e218bc55e64d695
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 6.8.0
2
+
3
+ * Drop support for Ruby 2.6 which reaches End of Life (EOL) on 31/03/2022
4
+ * Add support for Rails 7 by loosening the version constraint on `activeview` gem
5
+ * Fix deprecation notices caused by the bump in Ruby version
6
+
7
+ ## 6.7.8
8
+
9
+ * Fixes bug which reverts acronyms from being converted into abbr tags [#229](https://github.com/alphagov/govspeak/pull/229)
10
+
11
+ ## 6.7.7
12
+
13
+ * Fix broken HTML in CTA extension. [#226](https://github.com/alphagov/govspeak/pull/226)
14
+
15
+ ## 6.7.6
16
+
17
+ * Add draggable false to button markup and validation [#224](https://github.com/alphagov/govspeak/pull/224)
18
+
1
19
  ## 6.7.5
2
20
 
3
21
  * Fix footnotes in call-to-action boxes [222](https://github.com/alphagov/govspeak/pull/222)
data/README.md CHANGED
@@ -28,8 +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
- - [govuk-content-schema](https://github.com/alphagov/govuk-content-schemas) needs updating
32
- - [govpspeak-preview](https://github.com/alphagov/govspeak-preview) is worth updating
31
+ - [govpspeak-preview](https://github.com/alphagov/govspeak-preview) needs updating
33
32
 
34
33
  Any pages that use govspeak to generate Content will need to *republished* in order for the new changes to be reflected.
35
34
 
@@ -55,7 +55,7 @@ class Govspeak::HtmlSanitizer
55
55
  elements: Sanitize::Config::RELAXED[:elements] + %w[govspeak-embed-attachment govspeak-embed-attachment-link svg path].concat(allowed_elements),
56
56
  attributes: {
57
57
  :all => Sanitize::Config::RELAXED[:attributes][:all] + %w[role aria-label],
58
- "a" => Sanitize::Config::RELAXED[:attributes]["a"] + [:data],
58
+ "a" => Sanitize::Config::RELAXED[:attributes]["a"] + [:data] + %w[draggable],
59
59
  "svg" => Sanitize::Config::RELAXED[:attributes][:all] + %w[xmlns width height viewbox focusable],
60
60
  "path" => Sanitize::Config::RELAXED[:attributes][:all] + %w[fill d],
61
61
  "div" => [:data],
@@ -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: 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 = "6.7.5".freeze
2
+ VERSION = "6.8.0".freeze
3
3
  end
data/lib/govspeak.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "active_support"
1
2
  require "active_support/core_ext/hash"
2
3
  require "active_support/core_ext/array"
3
4
  require "erb"
@@ -224,7 +225,7 @@ module Govspeak
224
225
  text = text.strip
225
226
  href = href.strip
226
227
 
227
- %(\n<a role="button" class="#{button_classes}" href="#{href}" #{data_attribute}>#{text}</a>\n)
228
+ %(\n<a role="button" draggable="false" class="#{button_classes}" href="#{href}" #{data_attribute}>#{text}</a>\n)
228
229
  end
229
230
 
230
231
  extension("highlight-answer") do |body|
@@ -322,7 +323,7 @@ module Govspeak
322
323
  end
323
324
 
324
325
  extension("call-to-action", surrounded_by("$CTA")) do |body|
325
- doc = Kramdown::Document.new(body.strip).to_html
326
+ doc = Kramdown::Document.new(preprocess(body.strip), @options).to_html
326
327
  doc = %(\n<div class="call-to-action">\n#{doc}</div>\n)
327
328
  footnotes = body.scan(/\[\^(\d+)\]/).flatten
328
329
 
@@ -464,9 +465,10 @@ module Govspeak
464
465
  end
465
466
 
466
467
  def add_acronym_alt_text(html)
467
- @acronyms.each do |acronym|
468
- html.gsub!(acronym[0], "<abbr title=\"#{acronym[1].strip}\">#{acronym[0]}</abbr>")
469
- end
468
+ # FIXME: this code is buggy and replaces abbreviations in HTML tags - removing the functionality for now
469
+ # @acronyms.each do |acronym|
470
+ # html.gsub!(acronym[0], "<abbr title=\"#{acronym[1].strip}\">#{acronym[0]}</abbr>")
471
+ # end
470
472
  end
471
473
  end
472
474
  end
@@ -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" href="http://www.gov.uk">Start Now</a></p>
50
+ <p><a class="gem-c-button govuk-button" role="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" href="https://gov.uk/random">Line breaks</a></p>
68
+ <p><a class="gem-c-button govuk-button" role="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" href="https://gov.uk/random">Continue</a></p>
70
+ <p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Continue</a></p>
71
71
 
72
- <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
72
+ <p><a class="gem-c-button govuk-button" role="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" href="https://gov.uk/random">More line breaks</a></p>
78
+ <p><a class="gem-c-button govuk-button" role="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" href="https://gov.uk/random">Continue</a></p>
80
+ <p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Continue</a></p>
81
81
 
82
- <p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
82
+ <p><a class="gem-c-button govuk-button" role="button" draggable="false" href="https://gov.uk/random">Continue</a></p>
83
83
  )
84
84
  end
85
85
 
@@ -104,7 +104,7 @@ 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" href="https://gov.uk/random">Random page</a></p>
107
+ <p><a class="gem-c-button govuk-button" role="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>
@@ -440,6 +440,60 @@ Teston
440
440
  </div>)
441
441
  end
442
442
 
443
+ test_given_govspeak "
444
+ $CTA
445
+
446
+ This is a test:
447
+
448
+ s1. This is number 1.
449
+ s2. This is number 2.
450
+ s3. This is number 3.
451
+ s4. This is number 4.
452
+
453
+ $CTA" do
454
+ assert_html_output %(
455
+ <div class="call-to-action">
456
+ <p>This is a test:</p>
457
+
458
+ <ol class="steps">
459
+ <li>
460
+ <p>This is number 1.</p>
461
+ </li>
462
+ <li>
463
+ <p>This is number 2.</p>
464
+ </li>
465
+ <li>
466
+ <p>This is number 3.</p>
467
+ </li>
468
+ <li>
469
+ <p>This is number 4.</p>
470
+ </li>
471
+ </ol>
472
+ </div>
473
+ )
474
+ end
475
+
476
+ test_given_govspeak "
477
+ $CTA
478
+ [external link](http://www.external.com) some text
479
+ $CTA
480
+ " do
481
+ assert_html_output %(
482
+ <div class="call-to-action">
483
+ <p><a rel="external" href="http://www.external.com">external link</a> some text</p>
484
+ </div>)
485
+ end
486
+
487
+ test_given_govspeak "
488
+ $CTA
489
+ [internal link](http://www.not-external.com) some text
490
+ $CTA", document_domains: %w[www.not-external.com] do
491
+ assert_html_output %(
492
+ <div class="call-to-action">
493
+ <p><a href="http://www.not-external.com">internal link</a> some text</p>
494
+ </div>)
495
+ end
496
+
443
497
  test_given_govspeak "
444
498
  $CTA
445
499
  Click here to start the tool
@@ -994,43 +1048,44 @@ Teston
994
1048
  )
995
1049
  end
996
1050
 
997
- test_given_govspeak "
998
- $LegislativeList
999
- * 1. Item 1[^1] with an ACRONYM
1000
- * 2. Item 2[^2]
1001
- * 3. Item 3
1002
- $EndLegislativeList
1003
-
1004
- [^1]: Footnote definition one
1005
- [^2]: Footnote definition two with an ACRONYM
1006
-
1007
- *[ACRONYM]: This is the acronym explanation
1008
- " do
1009
- assert_html_output %(
1010
- <ol class="legislative-list">
1011
- <li>1. Item 1<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">[footnote 1]</a></sup> with an <abbr title="This is the acronym explanation">ACRONYM</abbr>
1012
- </li>
1013
- <li>2. Item 2<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">[footnote 2]</a></sup>
1014
- </li>
1015
- <li>3. Item 3</li>
1016
- </ol>
1017
-
1018
- <div class="footnotes" role="doc-endnotes">
1019
- <ol>
1020
- <li id="fn:1" role="doc-endnote">
1021
- <p>
1022
- Footnote definition one<a href="#fnref:1" class="reversefootnote" role="doc-backlink" aria-label="go to where this is referenced">↩</a>
1023
- </p>
1024
- </li>
1025
- <li id="fn:2" role="doc-endnote">
1026
- <p>
1027
- Footnote definition two with an <abbr title="This is the acronym explanation">ACRONYM</abbr><a href="#fnref:2" class="reversefootnote" role="doc-backlink" aria-label="go to where this is referenced">↩</a>
1028
- </p>
1029
- </li>
1030
- </ol>
1031
- </div>
1032
- )
1033
- end
1051
+ # FIXME: this code is buggy and replaces abbreviations in HTML tags - removing the functionality for now
1052
+ # test_given_govspeak "
1053
+ # $LegislativeList
1054
+ # * 1. Item 1[^1] with an ACRONYM
1055
+ # * 2. Item 2[^2]
1056
+ # * 3. Item 3
1057
+ # $EndLegislativeList
1058
+ #
1059
+ # [^1]: Footnote definition one
1060
+ # [^2]: Footnote definition two with an ACRONYM
1061
+ #
1062
+ # *[ACRONYM]: This is the acronym explanation
1063
+ # " do
1064
+ # assert_html_output %(
1065
+ # <ol class="legislative-list">
1066
+ # <li>1. Item 1<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">[footnote 1]</a></sup> with an <abbr title="This is the acronym explanation">ACRONYM</abbr>
1067
+ # </li>
1068
+ # <li>2. Item 2<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">[footnote 2]</a></sup>
1069
+ # </li>
1070
+ # <li>3. Item 3</li>
1071
+ # </ol>
1072
+ #
1073
+ # <div class="footnotes" role="doc-endnotes">
1074
+ # <ol>
1075
+ # <li id="fn:1" role="doc-endnote">
1076
+ # <p>
1077
+ # Footnote definition one<a href="#fnref:1" class="reversefootnote" role="doc-backlink" aria-label="go to where this is referenced">↩</a>
1078
+ # </p>
1079
+ # </li>
1080
+ # <li id="fn:2" role="doc-endnote">
1081
+ # <p>
1082
+ # Footnote definition two with an <abbr title="This is the acronym explanation">ACRONYM</abbr><a href="#fnref:2" class="reversefootnote" role="doc-backlink" aria-label="go to where this is referenced">↩</a>
1083
+ # </p>
1084
+ # </li>
1085
+ # </ol>
1086
+ # </div>
1087
+ # )
1088
+ # end
1034
1089
 
1035
1090
  test_given_govspeak "
1036
1091
  The quick brown
data/test/test_helper.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require "simplecov"
2
- require "simplecov-rcov"
3
2
 
4
3
  SimpleCov.start
5
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6
4
 
7
5
  $LOAD_PATH.unshift(File.expand_path("../lib")) unless $LOAD_PATH.include?(File.expand_path("../lib"))
8
6
 
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: 6.7.5
4
+ version: 6.8.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: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '7'
19
+ version: '6'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '5.0'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '7'
26
+ version: '6'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: addressable
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -194,16 +188,16 @@ dependencies:
194
188
  name: rubocop-govuk
195
189
  requirement: !ruby/object:Gem::Requirement
196
190
  requirements:
197
- - - "~>"
191
+ - - '='
198
192
  - !ruby/object:Gem::Version
199
- version: 4.1.0
193
+ version: 4.3.0
200
194
  type: :development
201
195
  prerelease: false
202
196
  version_requirements: !ruby/object:Gem::Requirement
203
197
  requirements:
204
- - - "~>"
198
+ - - '='
205
199
  - !ruby/object:Gem::Version
206
- version: 4.1.0
200
+ version: 4.3.0
207
201
  - !ruby/object:Gem::Dependency
208
202
  name: simplecov
209
203
  requirement: !ruby/object:Gem::Requirement
@@ -218,20 +212,6 @@ dependencies:
218
212
  - - ">="
219
213
  - !ruby/object:Gem::Version
220
214
  version: '0'
221
- - !ruby/object:Gem::Dependency
222
- name: simplecov-rcov
223
- requirement: !ruby/object:Gem::Requirement
224
- requirements:
225
- - - ">="
226
- - !ruby/object:Gem::Version
227
- version: '0'
228
- type: :development
229
- prerelease: false
230
- version_requirements: !ruby/object:Gem::Requirement
231
- requirements:
232
- - - ">="
233
- - !ruby/object:Gem::Version
234
- version: '0'
235
215
  description: |-
236
216
  A set of extensions to markdown layered on top of the kramdown
237
217
  library for use in the UK Government Single Domain project
@@ -340,36 +320,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
340
320
  requirements:
341
321
  - - ">="
342
322
  - !ruby/object:Gem::Version
343
- version: '2.6'
323
+ version: '2.7'
344
324
  required_rubygems_version: !ruby/object:Gem::Requirement
345
325
  requirements:
346
326
  - - ">="
347
327
  - !ruby/object:Gem::Version
348
328
  version: '0'
349
329
  requirements: []
350
- rubygems_version: 3.0.3
330
+ rubygems_version: 3.3.7
351
331
  signing_key:
352
332
  specification_version: 4
353
333
  summary: Markup language for single domain
354
334
  test_files:
355
- - test/test_helper.rb
335
+ - test/govspeak_test_helper.rb
356
336
  - test/blockquote_extra_quote_remover_test.rb
357
- - test/govspeak_images_bang_test.rb
358
- - test/govspeak_contacts_test.rb
359
- - test/govspeak_table_with_headers_test.rb
360
337
  - test/govspeak_link_extractor_test.rb
361
- - test/govspeak_attachments_image_test.rb
362
- - test/html_validator_test.rb
363
- - test/govspeak_button_test.rb
338
+ - test/govspeak_images_test.rb
339
+ - test/govspeak_link_test.rb
364
340
  - test/govspeak_extract_contact_content_ids_test.rb
365
- - test/govspeak_test_helper.rb
366
341
  - test/govspeak_footnote_test.rb
367
- - test/govspeak_link_test.rb
342
+ - test/presenters/h_card_presenter_test.rb
343
+ - test/govspeak_attachments_inline_test.rb
368
344
  - test/govspeak_structured_headers_test.rb
345
+ - test/test_helper.rb
346
+ - test/govspeak_button_test.rb
347
+ - test/govspeak_attachment_test.rb
369
348
  - test/html_sanitizer_test.rb
370
- - test/govspeak_images_test.rb
349
+ - test/govspeak_contacts_test.rb
350
+ - test/govspeak_attachments_image_test.rb
351
+ - test/govspeak_images_bang_test.rb
371
352
  - test/govspeak_test.rb
353
+ - test/govspeak_table_with_headers_test.rb
354
+ - test/html_validator_test.rb
372
355
  - test/govspeak_attachment_link_test.rb
373
- - test/govspeak_attachment_test.rb
374
- - test/presenters/h_card_presenter_test.rb
375
- - test/govspeak_attachments_inline_test.rb