govspeak 7.0.0 → 7.0.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: 3c3b8cb50ac3718a8e0721af172791562652e29dcbb871ef0c9627bd452a6dff
4
- data.tar.gz: 1d95d42b9f7f3302ecb7357811ad3e8e65856ea1f965dbb65a5a9e3564b0069b
3
+ metadata.gz: 8013e06cbc3f6f61be8953690c30bf05999ee7b405127bf9ab05566021dff5d6
4
+ data.tar.gz: d0db3c14af86be0a18662a1aacc9d6f058e0e72295957c478206e41dc97ca06f
5
5
  SHA512:
6
- metadata.gz: 9c3d91185cf37171cc0cfe0ea48abfd37451c069c5ab2cff7cd7e909cf2298e92fe67b11de5985f5257d0f962f991b8240c8a38c5771792d1add389d3629e7d6
7
- data.tar.gz: f3e4c332b35bcf5ab2587028d33cd85d4b933fd054334691c29febb3a85192214672ddc37a04f38117fce3e28b473068667d756e14e22e89f5614109e052cae5
6
+ metadata.gz: 07aedd1b981eb39f4b13327cb1192b598fbd0b90a1fc5f0a3c85d05e9baa428022435fe1891cbd576b824f410b5f9daf68b96d0742dfbdc05abcda1b946cdb9d
7
+ data.tar.gz: 75f8333f15d52a9e4e358abf8319daf1e05a2800f347937f2b63c52f1d860d691b30b72013ad07e310e2f9926ed63a8b344b5509271a9161a5a307353ea6feaf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 7.0.1
2
+
3
+ * Govspeak was stripping superscript from markdown when it shouldn't have. [#264](https://github.com/alphagov/govspeak/pull/264)
4
+
1
5
  ## 7.0.0
2
6
 
3
7
  * 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
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ..gemspec
4
4
  gemspec
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.content = el.content.gsub(/^# /, "")
89
- el.content = el.content.gsub(/[[:space:]]/, "") if el.content.blank? # Removes a strange whitespace in the cell if the cell is already blank.
90
- el.name = "td" if el.content.blank? # This prevents a `th` with nothing inside it; a `td` is preferable.
91
- el[:scope] = "col" if el.content.present? # `scope` shouldn't be used if there's nothing in the table heading.
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.content.match?(/^#($|\s.*$)/)
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.content.present? # This also prevents a `th` with nothing inside it; a `td` is preferable.
101
- el[:scope] = "row" if el.content.present? # `scope` shouldn't be used if there's nothing in the table heading.
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.content,
109
+ text: el.inner_html,
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.content = "[footnote #{footnote_number}]"
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?
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "7.0.0".freeze
2
+ VERSION = "7.0.1".freeze
3
3
  end
@@ -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,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" 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>
@@ -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.0
4
+ version: 7.0.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: 2022-08-18 00:00:00.000000000 Z
11
+ date: 2022-12-16 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.6.0
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.6.0
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.3.20
330
+ rubygems_version: 3.3.26
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/presenters/h_card_presenter_test.rb
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/govspeak_test_helper.rb
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/govspeak_images_test.rb
351
- - test/govspeak_attachment_link_test.rb
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/govspeak_table_with_headers_test.rb
355
- - test/govspeak_images_bang_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