govspeak 5.2.1 → 5.2.2

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
  SHA1:
3
- metadata.gz: dec9f9ee71166be1a0eead7618adabb81efd51f4
4
- data.tar.gz: cdc03d5927dac0271c21d8bba7dddbb565cccf27
3
+ metadata.gz: 0b89deebe8f9edfbab700411aad9fe2a35920ea1
4
+ data.tar.gz: 0c2bdf232a565f530966c9cf5799e6d856690e35
5
5
  SHA512:
6
- metadata.gz: 02d24aa502bf2dbb098d03f07fe991b978f272e479ee2beaaab52bb7a4c6fd0927f9e52d40339ec8fd48c432eb316657ae1557f46d0bc8cb44bf9b06eab69844
7
- data.tar.gz: 3cfbf2cc7011d73d4f35f223eb7c83946e7f1efba721a2a4f40e03ee1b5ffb75763a0a9671ae32e5c7a001d69c6437b5002ed8e0285ed3cd65f79583c8a65b31
6
+ metadata.gz: e70fdccd35a61cc375508ae191b2264ed294ad5d9c578d1776fdae7be705be5c21ed2dd8dc05fb28e97e2599faf655aaf164d24baab3cd986e8557fe1954e19a
7
+ data.tar.gz: 4d3bbd83d9a8b487bac5fc59bc1bb9ad55c6f93ea1fd489f9b44d41a68efd803a326da21ecfb3a2b16915b62031e381359440c2fab751144ade636c137dc53bb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 5.2.2
2
+ * Fix rendering buttons with inconsistent linebreaks seen in publishing [#118](https://github.com/alphagov/govspeak/pull/118)
3
+
1
4
  ## 5.2.1
2
5
  * Fix validation to make sure buttons are considered valid
3
6
  * Only allow buttons to be used on new lines, not when indented or inline within text (useful for guides) [#116](https://github.com/alphagov/govspeak/pull/116)
data/lib/govspeak.rb CHANGED
@@ -136,7 +136,7 @@ module Govspeak
136
136
  end
137
137
 
138
138
  extension('button', %r{
139
- ^ # Match start of line only, allows for indenting code examples
139
+ (?:\r|\n|^) # non-capturing match to make sure start of line and linebreak
140
140
  {button(.*?)} # match opening bracket and capture attributes
141
141
  \s* # any whitespace between opening bracket and link
142
142
  \[ # match start of link markdown
@@ -147,7 +147,7 @@ module Govspeak
147
147
  \) # match end of link text markdown
148
148
  \s* # any whitespace between opening bracket and link
149
149
  {\/button} # match ending bracket
150
- $ # Match end of line only, allows for indenting code examples
150
+ (?:\r|\n|$) # non-capturing match to make sure end of line and linebreak
151
151
  }x) { |attributes, text, href|
152
152
  button_classes = "button"
153
153
  button_classes << " button-start" if attributes =~ /start/
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "5.2.1".freeze
2
+ VERSION = "5.2.2".freeze
3
3
  end
@@ -79,4 +79,53 @@ class GovspeakTest < Minitest::Test
79
79
  </code></pre>
80
80
  }
81
81
  end
82
+
83
+ # Make sure button renders when typical linebreaks are before it, seen in publishing applications
84
+ 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
85
+ assert_html_output %{
86
+ <p><a role="button" class="button" href="https://gov.uk/random">Line breaks</a></p>
87
+
88
+ <p><a role="button" class="button" href="https://gov.uk/random">Continue</a></p>
89
+
90
+ <p><a role="button" class="button" href="https://gov.uk/random">Continue</a></p>
91
+ }
92
+ end
93
+
94
+ 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
95
+ assert_html_output %{
96
+ <p><a role="button" class="button" href="https://gov.uk/random">More line breaks</a></p>
97
+
98
+ <p><a role="button" class="button" href="https://gov.uk/random">Continue</a></p>
99
+
100
+ <p><a role="button" class="button" href="https://gov.uk/random">Continue</a></p>
101
+ }
102
+ end
103
+
104
+ test_given_govspeak %{
105
+ ## Register to vote
106
+
107
+ Introduction text about the service.
108
+
109
+ lorem lorem lorem
110
+ lorem lorem lorem
111
+
112
+ {button start}[Start Now](https://gov.uk/random){/button}
113
+
114
+ lorem lorem lorem
115
+ lorem lorem lorem
116
+ } do
117
+ assert_html_output %{
118
+ <h2 id="register-to-vote">Register to vote</h2>
119
+
120
+ <p>Introduction text about the service.</p>
121
+
122
+ <p>lorem lorem lorem
123
+ lorem lorem lorem</p>
124
+
125
+ <p><a role="button" class="button button-start" href="https://gov.uk/random">Start Now</a></p>
126
+
127
+ <p>lorem lorem lorem
128
+ lorem lorem lorem</p>
129
+ }
130
+ end
82
131
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govspeak
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Griffiths
@@ -320,18 +320,18 @@ signing_key:
320
320
  specification_version: 4
321
321
  summary: Markup language for single domain
322
322
  test_files:
323
+ - test/blockquote_extra_quote_remover_test.rb
323
324
  - test/govspeak_test_helper.rb
324
- - test/govspeak_test.rb
325
+ - test/govspeak_structured_headers_test.rb
325
326
  - test/govspeak_attachments_image_test.rb
326
- - test/with_deep_merge_test.rb
327
- - test/govspeak_link_test.rb
327
+ - test/govspeak_attachments_test.rb
328
328
  - test/test_helper.rb
329
- - test/html_validator_test.rb
330
- - test/blockquote_extra_quote_remover_test.rb
329
+ - test/govspeak_attachments_inline_test.rb
331
330
  - test/html_sanitizer_test.rb
332
- - test/govspeak_attachments_test.rb
333
331
  - test/govspeak_button_test.rb
334
- - test/govspeak_structured_headers_test.rb
335
- - test/presenters/h_card_presenter_test.rb
332
+ - test/with_deep_merge_test.rb
333
+ - test/html_validator_test.rb
334
+ - test/govspeak_test.rb
335
+ - test/govspeak_link_test.rb
336
336
  - test/govspeak_contacts_test.rb
337
- - test/govspeak_attachments_inline_test.rb
337
+ - test/presenters/h_card_presenter_test.rb