govspeak 5.0.2 → 5.0.3

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: 5e18592538eaa9b77c4ab24a8ff70cbae1c53d6a
4
- data.tar.gz: 3d6e5d43ffba151480e89c71c0f4675eeeecaf35
3
+ metadata.gz: d7009625d218a2a0653f0eb0ce8531b82700dbd4
4
+ data.tar.gz: c7b44ac063219357394b040641b5c6416ade46a3
5
5
  SHA512:
6
- metadata.gz: 8228d583156faaed9cfec6eda50eb29c223003db5af23bc008853ac09d1e0f004eafdc23727cbca6d43db715667d84c0a430fe81b479a425f5fd813660863d8c
7
- data.tar.gz: e9bcad53b426131c7b8c523c2abb4f24fdf1a5bf5450096ea60841e248240ea2cdd7137eb0de5857fb6c55aacfaa9f12a8bd1b3fd8d4e7b264a7433127f8c839
6
+ metadata.gz: 9e2c8cc7949cc19311b28c37713584c13d35f7293082491a21a05cd457bf59a9145dcd3b8efcb446c56ab40f8de41c39a49827d702a9e6ab041569ca6c23cfc9
7
+ data.tar.gz: 2bd2cf3a1ed5babbf9211dc77deb4ac7ed2ad1d0ad0f313627aff56ab81e1367ee5614b1451c56148eafebf17b25c864a77db43e57de62b3b3016ebbf304f4d7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 5.0.3
2
+
3
+ * Fix matching links/attachments/contacts by regex to use equality [#105](https://github.com/alphagov/govspeak/pull/105)
4
+
1
5
  ## 5.0.2
2
6
  * Loosen ActionView dependency to allow use with Rails
3
7
  5 [#99](https://github.com/alphagov/govspeak/pull/99)
data/README.md CHANGED
@@ -42,9 +42,12 @@ In addition to the [standard Markdown syntax](http://daringfireball.net/projects
42
42
 
43
43
  creates a callout with an info (i) icon.
44
44
 
45
- <div role="note" aria-label="Information" class="application-notice info-notice">
46
- <p>This is an information callout</p>
47
- </div>
45
+ ```html
46
+ <div role="note" aria-label="Information" class="application-notice info-notice">
47
+ <p>This is an information callout</p>
48
+ </div>
49
+ ```
50
+
48
51
 
49
52
  ### Warning callouts
50
53
 
@@ -52,9 +55,11 @@ creates a callout with an info (i) icon.
52
55
 
53
56
  creates a callout with a warning or alert (!) icon
54
57
 
55
- <div role="note" aria-label="Help" class="application-notice help-notice">
56
- <p>This is a warning callout</p>
57
- </div>
58
+ ```html
59
+ <div role="note" aria-label="Help" class="application-notice help-notice">
60
+ <p>This is a warning callout</p>
61
+ </div>
62
+ ```
58
63
 
59
64
  ### Example callout
60
65
 
@@ -64,9 +69,11 @@ creates a callout with a warning or alert (!) icon
64
69
 
65
70
  creates an example box
66
71
 
67
- <div class="example">
68
- <p><strong>Example:</strong> Open the pod bay doors</p>
69
- </div>
72
+ ```html
73
+ <div class="example">
74
+ <p><strong>Example:</strong> Open the pod bay doors</p>
75
+ </div>
76
+ ```
70
77
 
71
78
  ## Highlights
72
79
 
@@ -76,9 +83,11 @@ creates an example box
76
83
 
77
84
  highlights the enclosed text in yellow
78
85
 
79
- <h3 role="note" aria-label="Important" class="advisory">
80
- <span>This is a very important message or warning</span>
81
- </h3>
86
+ ```html
87
+ <h3 role="note" aria-label="Important" class="advisory">
88
+ <span>This is a very important message or warning</span>
89
+ </h3>
90
+ ```
82
91
 
83
92
  ### Answer
84
93
 
@@ -88,9 +97,11 @@ highlights the enclosed text in yellow
88
97
 
89
98
  creates a large highlight box with optional preamble text and giant text denoted with `**`
90
99
 
91
- <div class="highlight-answer">
92
- <p>The VAT rate is <em>20%</em></p>
93
- </div>
100
+ ```html
101
+ <div class="highlight-answer">
102
+ <p>The VAT rate is <em>20%</em></p>
103
+ </div>
104
+ ```
94
105
 
95
106
  ### Statistic headline
96
107
 
@@ -124,9 +135,15 @@ Creates the following:
124
135
 
125
136
  creates a contact box
126
137
 
127
- <div class="contact">
128
- <p><strong>Student Finance England</strong><br><strong>Telephone:</strong> 0845 300 50 90<br><strong>Minicom:</strong> 0845 604 44 34</p>
129
- </div>
138
+ ```html
139
+ <div class="contact">
140
+ <p>
141
+ <strong>Student Finance England</strong><br>
142
+ <strong>Telephone:</strong> 0845 300 50 90<br>
143
+ <strong>Minicom:</strong> 0845 604 44 34
144
+ </p>
145
+ </div>
146
+ ```
130
147
 
131
148
  ### Address
132
149
 
@@ -138,11 +155,17 @@ creates a contact box
138
155
 
139
156
  creates an address box
140
157
 
141
- <div class="address"><div class="adr org fn"><p>
142
- Hercules House
143
- <br>Hercules Road
144
- <br>London SE1 7DU
145
- <br></p></div></div>
158
+ ```html
159
+ <div class="address">
160
+ <div class="adr org fn">
161
+ <p>
162
+ Hercules House<br>
163
+ Hercules Road<br>
164
+ London SE1 7DU<br>
165
+ </p>
166
+ </div>
167
+ </div>
168
+ ```
146
169
 
147
170
  ## Downloads
148
171
 
@@ -154,9 +177,11 @@ creates an address box
154
177
 
155
178
  creates a file download box
156
179
 
157
- <div class="form-download">
158
- <p><a href="http://example.com/" title="Example form" rel="external">An example form download link.</a></p>
159
- </div>
180
+ ```html
181
+ <div class="form-download">
182
+ <p><a href="http://example.com/" title="Example form" rel="external">An example form download link.</a></p>
183
+ </div>
184
+ ```
160
185
 
161
186
  ## Place
162
187
 
@@ -166,9 +191,11 @@ creates a file download box
166
191
 
167
192
  creates a place box
168
193
 
169
- <div class="place">
170
- <p>This is a place</p>
171
- </div>
194
+ ```html
195
+ <div class="place">
196
+ <p>This is a place</p>
197
+ </div>
198
+ ```
172
199
 
173
200
  ## Information
174
201
 
@@ -178,9 +205,11 @@ creates a place box
178
205
 
179
206
  creates an information box
180
207
 
181
- <div class="information">
182
- <p>This is information</p>
183
- </div>
208
+ ```html
209
+ <div class="information">
210
+ <p>This is information</p>
211
+ </div>
212
+ ```
184
213
 
185
214
  ## Additional Information
186
215
 
@@ -190,9 +219,11 @@ creates an information box
190
219
 
191
220
  creates an additional information box
192
221
 
193
- <div class="additional-information">
194
- <p>This is additional information</p>
195
- </div>
222
+ ```html
223
+ <div class="additional-information">
224
+ <p>This is additional information</p>
225
+ </div>
226
+ ```
196
227
 
197
228
  ## Call to Action
198
229
 
@@ -202,9 +233,11 @@ creates an additional information box
202
233
 
203
234
  creates an additional information box
204
235
 
205
- <div class="call-to-action">
206
- <p>This is a call to action</p>
207
- </div>
236
+ ```html
237
+ <div class="call-to-action">
238
+ <p>This is a call to action</p>
239
+ </div>
240
+ ```
208
241
 
209
242
  ## Summary
210
243
 
@@ -214,9 +247,11 @@ creates an additional information box
214
247
 
215
248
  creates a summary box
216
249
 
217
- <div class="summary">
218
- <p>This is a summary</p>
219
- </div>
250
+ ```html
251
+ <div class="summary">
252
+ <p>This is a summary</p>
253
+ </div>
254
+ ```
220
255
 
221
256
  ## External Link
222
257
 
@@ -224,7 +259,9 @@ creates a summary box
224
259
 
225
260
  creates a link specified as external
226
261
 
227
- <a href="https://example.com/report" rel="external">External Report</a>
262
+ ```html
263
+ <a href="https://example.com/report" rel="external">External Report</a>
264
+ ```
228
265
 
229
266
  ## Steps
230
267
 
@@ -264,13 +301,15 @@ For lists where you want to specify a number of items to be highlighted as prior
264
301
 
265
302
  creates a list with priority items flagged with a class
266
303
 
267
- <ul>
268
- <li class="primary-item">Item 1</li>
269
- <li class="primary-item">Item 2</li>
270
- <li class="primary-item">Item 3</li>
271
- <li>Item 4</li>
272
- <li>Item 5</li>
273
- </ul>
304
+ ```html
305
+ <ul>
306
+ <li class="primary-item">Item 1</li>
307
+ <li class="primary-item">Item 2</li>
308
+ <li class="primary-item">Item 3</li>
309
+ <li>Item 4</li>
310
+ <li>Item 5</li>
311
+ </ul>
312
+ ```
274
313
 
275
314
  ## Devolved content
276
315
 
@@ -283,12 +322,14 @@ creates a list with priority items flagged with a class
283
322
 
284
323
  will create a box for the specified locality
285
324
 
286
- <div class="devolved-content england">
287
- <p class="devolved-header">This section applies to England</p>
288
- <div class="devolved-body">
289
- <p>content goes here</p>
290
- </div>
291
- </div>
325
+ ```html
326
+ <div class="devolved-content england">
327
+ <p class="devolved-header">This section applies to England</p>
328
+ <div class="devolved-body">
329
+ <p>content goes here</p>
330
+ </div>
331
+ </div>
332
+ ```
292
333
 
293
334
  ## Barcharts
294
335
 
@@ -301,18 +342,21 @@ rendered as a bar chart.
301
342
  {barchart}
302
343
 
303
344
  will be rendered as
304
- <table class="js-barchart-table mc-auto-outdent">
305
- <thead>
306
- <tr>
307
- <th>col</th>
308
- </tr>
309
- </thead>
310
- <tbody>
311
- <tr>
312
- <td>val</td>
313
- </tr>
314
- </tbody>
315
- </table>
345
+
346
+ ```html
347
+ <table class="js-barchart-table mc-auto-outdent">
348
+ <thead>
349
+ <tr>
350
+ <th>col</th>
351
+ </tr>
352
+ </thead>
353
+ <tbody>
354
+ <tr>
355
+ <td>val</td>
356
+ </tr>
357
+ </tbody>
358
+ </table>
359
+ ```
316
360
 
317
361
  ## Embedded Content
318
362
 
@@ -345,22 +389,24 @@ with options provided
345
389
 
346
390
  will output an attachment box
347
391
 
348
- <section class="attachment embedded">
349
- <div class="attachment-thumb">
350
- <a href="http://example.com/test.pdf" aria-hidden="true" class="embedded"><img src="/images/pub-cover.png" alt="Pub cover"></a>
351
- </div>
352
- <div class="attachment-details">
353
- <h2 class="title">
354
- <a href="http://example.com/test.pdf" aria-describedby="attachment-123-accessibility-help">Attachment Title</a>
355
- </h2>
356
- <p class="metadata">
357
- <span class="references">Ref: ISBN <span class="isbn">isbn-123</span></span>
358
- </p>
359
- <p>
360
- <a href="http://example.com/order" class="order_url" title="Order a copy of the publication">Order a copy</a>(<span class="price">£12.30</span>)
361
- </p>
362
- </div>
363
- </section>
392
+ ```html
393
+ <section class="attachment embedded">
394
+ <div class="attachment-thumb">
395
+ <a href="http://example.com/test.pdf" aria-hidden="true" class="embedded"><img src="/images/pub-cover.png" alt="Pub cover"></a>
396
+ </div>
397
+ <div class="attachment-details">
398
+ <h2 class="title">
399
+ <a href="http://example.com/test.pdf" aria-describedby="attachment-123-accessibility-help">Attachment Title</a>
400
+ </h2>
401
+ <p class="metadata">
402
+ <span class="references">Ref: ISBN <span class="isbn">isbn-123</span></span>
403
+ </p>
404
+ <p>
405
+ <a href="http://example.com/order" class="order_url" title="Order a copy of the publication">Order a copy</a>(<span class="price">£12.30</span>)
406
+ </p>
407
+ </div>
408
+ </section>
409
+ ```
364
410
 
365
411
  ### Inline Attachment
366
412
 
@@ -382,7 +428,9 @@ with options provided
382
428
 
383
429
  will output an attachment within a block of text
384
430
 
385
- <p>Details referenced in <span class="attachment-inline"><a href="http://example.com/my-thorough-study.pdf">My Thorough Study</a></span>
431
+ ```html
432
+ <p>Details referenced in <span class="attachment-inline"><a href="http://example.com/my-thorough-study.pdf">My Thorough Study</a></span></p>
433
+ ```
386
434
 
387
435
  ### Image Attachments
388
436
 
@@ -404,7 +452,13 @@ with options provided
404
452
 
405
453
  will output a image section
406
454
 
407
- <figure class="image embedded"><div class="img"><img src="http://example.com/lovely-landscape.jpg" alt="A Lovely Landscape"></div></figure>
455
+ ```html
456
+ <figure class="image embedded">
457
+ <div class="img">
458
+ <img src="http://example.com/lovely-landscape.jpg" alt="A Lovely Landscape">
459
+ </div>
460
+ </figure>
461
+ ```
408
462
 
409
463
  ### Link
410
464
 
@@ -426,7 +480,9 @@ with options provided
426
480
 
427
481
  will output
428
482
 
429
- <p>A link to <a href="http://example.com">An excellent website</a></p>
483
+ ```html
484
+ <p>A link to <a href="http://example.com">An excellent website</a></p>
485
+ ```
430
486
 
431
487
  ### Contact
432
488
 
@@ -450,20 +506,22 @@ with options provided
450
506
 
451
507
  will output
452
508
 
453
- <div id="contact_123" class="contact">
454
- <div class="content">
455
- <h3>Government Digital Service</h3>
456
- <div class="vcard contact-inner">
457
- <div class="email-url-number">
458
- <p class="email">
459
- <span class="type">Email</span>
460
- <a href="mailto:people@digital.cabinet-office.gov.uk" class="email">people@digital.cabinet-office.gov.uk</a>
461
- </p>
462
- <p class="tel">
463
- <span class="type">helpdesk</span>
464
- +4412345 67890
465
- </p>
466
- </div>
467
- </div>
509
+ ```html
510
+ <div id="contact_123" class="contact">
511
+ <div class="content">
512
+ <h3>Government Digital Service</h3>
513
+ <div class="vcard contact-inner">
514
+ <div class="email-url-number">
515
+ <p class="email">
516
+ <span class="type">Email</span>
517
+ <a href="mailto:people@digital.cabinet-office.gov.uk" class="email">people@digital.cabinet-office.gov.uk</a>
518
+ </p>
519
+ <p class="tel">
520
+ <span class="type">helpdesk</span>
521
+ +4412345 67890
522
+ </p>
468
523
  </div>
469
524
  </div>
525
+ </div>
526
+ </div>
527
+ ```
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "5.0.2"
2
+ VERSION = "5.0.3"
3
3
  end
data/lib/govspeak.rb CHANGED
@@ -190,7 +190,7 @@ module Govspeak
190
190
  end
191
191
 
192
192
  extension('attachment', /\[embed:attachments:(?!inline:|image:)\s*(.*?)\s*\]/) do |content_id, body|
193
- attachment = attachments.detect { |a| a[:content_id].match(content_id) }
193
+ attachment = attachments.detect { |a| a[:content_id] == content_id }
194
194
  next "" unless attachment
195
195
  attachment = AttachmentPresenter.new(attachment)
196
196
  content = File.read(__dir__ + '/templates/attachment.html.erb')
@@ -198,7 +198,7 @@ module Govspeak
198
198
  end
199
199
 
200
200
  extension('attachment inline', /\[embed:attachments:inline:\s*(.*?)\s*\]/) do |content_id|
201
- attachment = attachments.detect { |a| a[:content_id].match(content_id) }
201
+ attachment = attachments.detect { |a| a[:content_id] == content_id }
202
202
  next "" unless attachment
203
203
  attachment = AttachmentPresenter.new(attachment)
204
204
  span_id = attachment.id ? %{ id="attachment_#{attachment.id}"} : ""
@@ -210,7 +210,7 @@ module Govspeak
210
210
  end
211
211
 
212
212
  extension('attachment image', /\[embed:attachments:image:\s*(.*?)\s*\]/) do |content_id|
213
- attachment = attachments.detect { |a| a[:content_id].match(content_id) }
213
+ attachment = attachments.detect { |a| a[:content_id] == content_id }
214
214
  next "" unless attachment
215
215
  attachment = AttachmentPresenter.new(attachment)
216
216
  title = (attachment.title || "").tr("\n", " ")
@@ -300,7 +300,7 @@ module Govspeak
300
300
  end
301
301
 
302
302
  extension('embed link', /\[embed:link:\s*(.*?)\s*\]/) do |content_id|
303
- link = links.detect { |l| l[:content_id].match(content_id) }
303
+ link = links.detect { |l| l[:content_id] == content_id }
304
304
  next "" unless link
305
305
  if link[:url]
306
306
  "[#{link[:title]}](#{link[:url]})"
@@ -315,7 +315,7 @@ module Govspeak
315
315
  private :render_hcard_address
316
316
 
317
317
  extension('Contact', /\[Contact:\s*(.*?)\s*\]/) do |content_id|
318
- contact = contacts.detect { |c| c[:content_id].match(content_id) }
318
+ contact = contacts.detect { |c| c[:content_id] == content_id }
319
319
  next "" unless contact
320
320
  contact = ContactPresenter.new(contact)
321
321
  @renderer ||= ERB.new(File.read(__dir__ + '/templates/contact.html.erb'))
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.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Griffiths
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-11 00:00:00.000000000 Z
12
+ date: 2017-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: kramdown
@@ -233,6 +233,20 @@ dependencies:
233
233
  - - ">="
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
+ - !ruby/object:Gem::Dependency
237
+ name: govuk-lint
238
+ requirement: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
243
+ type: :development
244
+ prerelease: false
245
+ version_requirements: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
236
250
  description: |-
237
251
  A set of extensions to markdown layered on top of the kramdown
238
252
  library for use in the UK Government Single Domain project
@@ -305,17 +319,17 @@ signing_key:
305
319
  specification_version: 4
306
320
  summary: Markup language for single domain
307
321
  test_files:
308
- - test/govspeak_contacts_test.rb
309
- - test/govspeak_test_helper.rb
322
+ - test/govspeak_structured_headers_test.rb
323
+ - test/with_deep_merge_test.rb
310
324
  - test/blockquote_extra_quote_remover_test.rb
311
- - test/govspeak_test.rb
325
+ - test/govspeak_test_helper.rb
326
+ - test/govspeak_link_test.rb
327
+ - test/govspeak_contacts_test.rb
312
328
  - test/test_helper.rb
313
- - test/govspeak_attachments_test.rb
314
- - test/presenters/h_card_presenter_test.rb
329
+ - test/html_validator_test.rb
330
+ - test/html_sanitizer_test.rb
315
331
  - test/govspeak_attachments_inline_test.rb
316
- - test/with_deep_merge_test.rb
332
+ - test/govspeak_test.rb
333
+ - test/govspeak_attachments_test.rb
317
334
  - test/govspeak_attachments_image_test.rb
318
- - test/html_sanitizer_test.rb
319
- - test/html_validator_test.rb
320
- - test/govspeak_structured_headers_test.rb
321
- - test/govspeak_link_test.rb
335
+ - test/presenters/h_card_presenter_test.rb