govspeak 6.5.0 → 6.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -2
- data/README.md +6 -5
- data/Rakefile +7 -4
- data/lib/govspeak.rb +116 -116
- data/lib/govspeak/header_extractor.rb +1 -1
- data/lib/govspeak/html_sanitizer.rb +12 -9
- data/lib/govspeak/kramdown_overrides.rb +2 -2
- data/lib/govspeak/link_extractor.rb +6 -6
- data/lib/govspeak/post_processor.rb +34 -14
- data/lib/govspeak/presenters/attachment_presenter.rb +39 -39
- data/lib/govspeak/presenters/contact_presenter.rb +2 -2
- data/lib/govspeak/presenters/h_card_presenter.rb +3 -3
- data/lib/govspeak/presenters/image_presenter.rb +4 -4
- data/lib/govspeak/structured_header_extractor.rb +2 -2
- data/lib/govspeak/version.rb +1 -1
- data/lib/kramdown/parser/govuk.rb +6 -7
- data/test/blockquote_extra_quote_remover_test.rb +24 -26
- data/test/govspeak_attachment_link_test.rb +0 -2
- data/test/govspeak_attachment_test.rb +0 -2
- data/test/govspeak_attachments_image_test.rb +12 -14
- data/test/govspeak_attachments_inline_test.rb +22 -24
- data/test/govspeak_button_test.rb +29 -31
- data/test/govspeak_contacts_test.rb +29 -31
- data/test/govspeak_extract_contact_content_ids_test.rb +1 -3
- data/test/govspeak_images_bang_test.rb +37 -39
- data/test/govspeak_images_test.rb +43 -45
- data/test/govspeak_link_extractor_test.rb +1 -1
- data/test/govspeak_link_test.rb +1 -3
- data/test/govspeak_structured_headers_test.rb +7 -6
- data/test/govspeak_table_with_headers_test.rb +68 -21
- data/test/govspeak_test.rb +98 -101
- data/test/govspeak_test_helper.rb +1 -1
- data/test/html_sanitizer_test.rb +17 -9
- data/test/html_validator_test.rb +2 -2
- data/test/presenters/h_card_presenter_test.rb +39 -41
- data/test/test_helper.rb +12 -8
- metadata +52 -40
data/test/govspeak_test.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
|
1
|
+
require "test_helper"
|
2
|
+
require "govspeak_test_helper"
|
2
3
|
|
3
|
-
require
|
4
|
-
require 'govspeak_test_helper'
|
5
|
-
|
6
|
-
require 'ostruct'
|
4
|
+
require "ostruct"
|
7
5
|
|
8
6
|
class GovspeakTest < Minitest::Test
|
9
7
|
include GovspeakTestHelper
|
@@ -20,46 +18,46 @@ class GovspeakTest < Minitest::Test
|
|
20
18
|
|
21
19
|
test "strips forbidden unicode characters" do
|
22
20
|
rendered = Govspeak::Document.new(
|
23
|
-
"this is text with forbidden characters \
|
21
|
+
"this is text with forbidden characters \u0008\u000b\ufffe\u{2ffff}\u{5fffe}",
|
24
22
|
).to_html
|
25
23
|
assert_equal "<p>this is text with forbidden characters</p>\n", rendered
|
26
24
|
end
|
27
25
|
|
28
26
|
test "highlight-answer block extension" do
|
29
27
|
rendered = Govspeak::Document.new("this \n{::highlight-answer}Lead in to *BIG TEXT*\n{:/highlight-answer}").to_html
|
30
|
-
assert_equal %
|
28
|
+
assert_equal %(<p>this</p>\n\n<div class="highlight-answer">\n<p>Lead in to <em>BIG TEXT</em></p>\n</div>\n), rendered
|
31
29
|
end
|
32
30
|
|
33
31
|
test "stat-headline block extension" do
|
34
32
|
rendered = Govspeak::Document.new("this \n{stat-headline}*13.8bn* Age of the universe in years{/stat-headline}").to_html
|
35
|
-
assert_equal %
|
33
|
+
assert_equal %(<p>this</p>\n\n<aside class="stat-headline">\n<p><em>13.8bn</em> Age of the universe in years</p>\n</aside>\n), rendered
|
36
34
|
end
|
37
35
|
|
38
36
|
test "extracts headers with text, level and generated id" do
|
39
|
-
document = Govspeak::Document.new %
|
37
|
+
document = Govspeak::Document.new %(
|
40
38
|
# Big title
|
41
39
|
|
42
40
|
### Small subtitle
|
43
41
|
|
44
42
|
## Medium title
|
45
|
-
|
43
|
+
)
|
46
44
|
assert_equal [
|
47
|
-
Govspeak::Header.new(
|
48
|
-
Govspeak::Header.new(
|
49
|
-
Govspeak::Header.new(
|
45
|
+
Govspeak::Header.new("Big title", 1, "big-title"),
|
46
|
+
Govspeak::Header.new("Small subtitle", 3, "small-subtitle"),
|
47
|
+
Govspeak::Header.new("Medium title", 2, "medium-title"),
|
50
48
|
], document.headers
|
51
49
|
end
|
52
50
|
|
53
51
|
test "extracts different ids for duplicate headers" do
|
54
52
|
document = Govspeak::Document.new("## Duplicate header\n\n## Duplicate header")
|
55
53
|
assert_equal [
|
56
|
-
Govspeak::Header.new(
|
57
|
-
Govspeak::Header.new(
|
54
|
+
Govspeak::Header.new("Duplicate header", 2, "duplicate-header"),
|
55
|
+
Govspeak::Header.new("Duplicate header", 2, "duplicate-header-1"),
|
58
56
|
], document.headers
|
59
57
|
end
|
60
58
|
|
61
59
|
test "extracts headers when nested inside blocks" do
|
62
|
-
document = Govspeak::Document.new %
|
60
|
+
document = Govspeak::Document.new %(
|
63
61
|
# First title
|
64
62
|
|
65
63
|
<div markdown="1">
|
@@ -74,24 +72,24 @@ class GovspeakTest < Minitest::Test
|
|
74
72
|
### Second double subtitle
|
75
73
|
</div>
|
76
74
|
</div>
|
77
|
-
|
75
|
+
)
|
78
76
|
assert_equal [
|
79
|
-
Govspeak::Header.new(
|
80
|
-
Govspeak::Header.new(
|
81
|
-
Govspeak::Header.new(
|
82
|
-
Govspeak::Header.new(
|
77
|
+
Govspeak::Header.new("First title", 1, "first-title"),
|
78
|
+
Govspeak::Header.new("Nested subtitle", 2, "nested-subtitle"),
|
79
|
+
Govspeak::Header.new("Double nested subtitle", 3, "double-nested-subtitle"),
|
80
|
+
Govspeak::Header.new("Second double subtitle", 3, "second-double-subtitle"),
|
83
81
|
], document.headers
|
84
82
|
end
|
85
83
|
|
86
84
|
test "extracts headers with explicitly specified ids" do
|
87
|
-
document = Govspeak::Document.new %
|
85
|
+
document = Govspeak::Document.new %(
|
88
86
|
# First title
|
89
87
|
|
90
88
|
## Second title {#special}
|
91
|
-
|
89
|
+
)
|
92
90
|
assert_equal [
|
93
|
-
Govspeak::Header.new(
|
94
|
-
Govspeak::Header.new(
|
91
|
+
Govspeak::Header.new("First title", 1, "first-title"),
|
92
|
+
Govspeak::Header.new("Second title", 2, "special"),
|
95
93
|
], document.headers
|
96
94
|
end
|
97
95
|
|
@@ -102,13 +100,13 @@ class GovspeakTest < Minitest::Test
|
|
102
100
|
end
|
103
101
|
|
104
102
|
test "trailing space after the address should not prevent parsing" do
|
105
|
-
input = %
|
103
|
+
input = %($A
|
106
104
|
123 Test Street
|
107
105
|
Testcase Cliffs
|
108
106
|
Teston
|
109
|
-
0123 456 7890 $A
|
107
|
+
0123 456 7890 $A )
|
110
108
|
doc = Govspeak::Document.new(input)
|
111
|
-
assert_equal %
|
109
|
+
assert_equal %(\n<div class="address"><div class="adr org fn"><p>\n123 Test Street<br>Testcase Cliffs<br>Teston<br>0123 456 7890 \n</p></div></div>\n), doc.to_html
|
112
110
|
end
|
113
111
|
|
114
112
|
test "should convert barchart" do
|
@@ -119,7 +117,7 @@ Teston
|
|
119
117
|
{barchart}
|
120
118
|
GOVSPEAK
|
121
119
|
html = Govspeak::Document.new(input).to_html
|
122
|
-
assert_equal %
|
120
|
+
assert_equal %(<table class=\"js-barchart-table mc-auto-outdent\">\n <thead>\n <tr>\n <th scope="col">col</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>val</td>\n </tr>\n </tbody>\n</table>\n), html
|
123
121
|
end
|
124
122
|
|
125
123
|
test "should convert barchart with stacked compact and negative" do
|
@@ -130,27 +128,27 @@ Teston
|
|
130
128
|
{barchart stacked compact negative}
|
131
129
|
GOVSPEAK
|
132
130
|
html = Govspeak::Document.new(input).to_html
|
133
|
-
assert_equal %
|
131
|
+
assert_equal %(<table class=\"js-barchart-table mc-stacked compact mc-negative mc-auto-outdent\">\n <thead>\n <tr>\n <th scope="col">col</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>val</td>\n </tr>\n </tbody>\n</table>\n), html
|
134
132
|
end
|
135
133
|
|
136
134
|
test "address div is separated from paragraph text by a couple of line-breaks" do
|
137
135
|
# else kramdown processes address div as part of paragraph text and escapes HTML
|
138
|
-
input = %
|
136
|
+
input = %(Paragraph1
|
139
137
|
|
140
138
|
$A
|
141
139
|
123 Test Street
|
142
140
|
Testcase Cliffs
|
143
141
|
Teston
|
144
|
-
0123 456 7890 $A
|
142
|
+
0123 456 7890 $A)
|
145
143
|
doc = Govspeak::Document.new(input)
|
146
|
-
assert_equal %
|
144
|
+
assert_equal %(<p>Paragraph1</p>\n\n<div class="address"><div class="adr org fn"><p>\n123 Test Street<br>Testcase Cliffs<br>Teston<br>0123 456 7890 \n</p></div></div>\n), doc.to_html
|
147
145
|
end
|
148
146
|
|
149
147
|
test_given_govspeak("^ I am very informational ^") do
|
150
|
-
assert_html_output %
|
148
|
+
assert_html_output %(
|
151
149
|
<div role="note" aria-label="Information" class="application-notice info-notice">
|
152
150
|
<p>I am very informational</p>
|
153
|
-
</div>
|
151
|
+
</div>)
|
154
152
|
assert_text_output "I am very informational"
|
155
153
|
end
|
156
154
|
|
@@ -161,28 +159,28 @@ Teston
|
|
161
159
|
end
|
162
160
|
|
163
161
|
test_given_govspeak "The following is very informational\n^ I am very informational ^" do
|
164
|
-
assert_html_output %
|
162
|
+
assert_html_output %(
|
165
163
|
<p>The following is very informational</p>
|
166
164
|
|
167
165
|
<div role="note" aria-label="Information" class="application-notice info-notice">
|
168
166
|
<p>I am very informational</p>
|
169
|
-
</div>
|
167
|
+
</div>)
|
170
168
|
assert_text_output "The following is very informational I am very informational"
|
171
169
|
end
|
172
170
|
|
173
171
|
test_given_govspeak "^ I am very informational" do
|
174
|
-
assert_html_output %
|
172
|
+
assert_html_output %(
|
175
173
|
<div role="note" aria-label="Information" class="application-notice info-notice">
|
176
174
|
<p>I am very informational</p>
|
177
|
-
</div>
|
175
|
+
</div>)
|
178
176
|
assert_text_output "I am very informational"
|
179
177
|
end
|
180
178
|
|
181
179
|
test_given_govspeak "@ I am very important @" do
|
182
|
-
assert_html_output %
|
180
|
+
assert_html_output %(
|
183
181
|
<div role="note" aria-label="Important" class="advisory">
|
184
182
|
<p><strong>I am very important</strong></p>
|
185
|
-
</div>
|
183
|
+
</div>)
|
186
184
|
assert_text_output "I am very important"
|
187
185
|
end
|
188
186
|
|
@@ -190,50 +188,50 @@ Teston
|
|
190
188
|
The following is very important
|
191
189
|
@ I am very important @
|
192
190
|
" do
|
193
|
-
assert_html_output %
|
191
|
+
assert_html_output %(
|
194
192
|
<p>The following is very important</p>
|
195
193
|
|
196
194
|
<div role="note" aria-label="Important" class="advisory">
|
197
195
|
<p><strong>I am very important</strong></p>
|
198
|
-
</div>
|
196
|
+
</div>)
|
199
197
|
assert_text_output "The following is very important I am very important"
|
200
198
|
end
|
201
199
|
|
202
200
|
test_given_govspeak "% I am very helpful %" do
|
203
|
-
assert_html_output %
|
201
|
+
assert_html_output %(
|
204
202
|
<div role="note" aria-label="Warning" class="application-notice help-notice">
|
205
203
|
<p>I am very helpful</p>
|
206
|
-
</div>
|
204
|
+
</div>)
|
207
205
|
assert_text_output "I am very helpful"
|
208
206
|
end
|
209
207
|
|
210
208
|
test_given_govspeak "The following is very helpful\n% I am very helpful %" do
|
211
|
-
assert_html_output %
|
209
|
+
assert_html_output %(
|
212
210
|
<p>The following is very helpful</p>
|
213
211
|
|
214
212
|
<div role="note" aria-label="Warning" class="application-notice help-notice">
|
215
213
|
<p>I am very helpful</p>
|
216
|
-
</div>
|
214
|
+
</div>)
|
217
215
|
assert_text_output "The following is very helpful I am very helpful"
|
218
216
|
end
|
219
217
|
|
220
218
|
test_given_govspeak "## Hello ##\n\n% I am very helpful %\r\n### Young Workers ###\n\n" do
|
221
|
-
assert_html_output %
|
219
|
+
assert_html_output %(
|
222
220
|
<h2 id="hello">Hello</h2>
|
223
221
|
|
224
222
|
<div role="note" aria-label="Warning" class="application-notice help-notice">
|
225
223
|
<p>I am very helpful</p>
|
226
224
|
</div>
|
227
225
|
|
228
|
-
<h3 id="young-workers">Young Workers</h3>
|
226
|
+
<h3 id="young-workers">Young Workers</h3>)
|
229
227
|
assert_text_output "Hello I am very helpful Young Workers"
|
230
228
|
end
|
231
229
|
|
232
230
|
test_given_govspeak "% I am very helpful" do
|
233
|
-
assert_html_output %
|
231
|
+
assert_html_output %(
|
234
232
|
<div role="note" aria-label="Warning" class="application-notice help-notice">
|
235
233
|
<p>I am very helpful</p>
|
236
|
-
</div>
|
234
|
+
</div>)
|
237
235
|
assert_text_output "I am very helpful"
|
238
236
|
end
|
239
237
|
|
@@ -251,7 +249,7 @@ Teston
|
|
251
249
|
HTML
|
252
250
|
|
253
251
|
*[HTML]: Hyper Text Markup Language" do
|
254
|
-
assert_html_output %
|
252
|
+
assert_html_output %(<p><abbr title="Hyper Text Markup Language">HTML</abbr></p>)
|
255
253
|
assert_text_output "HTML"
|
256
254
|
end
|
257
255
|
|
@@ -311,12 +309,12 @@ Teston
|
|
311
309
|
end
|
312
310
|
|
313
311
|
test "should be able to override default 'document_domains' option" do
|
314
|
-
html = Govspeak::Document.new("[internal link](http://www.not-external.com)", document_domains: %w
|
312
|
+
html = Govspeak::Document.new("[internal link](http://www.not-external.com)", document_domains: %w[www.not-external.com]).to_html
|
315
313
|
refute html.include?('rel="external"'), "should not consider www.not-external.com as an external url"
|
316
314
|
end
|
317
315
|
|
318
316
|
test "should be able to supply multiple domains for 'document_domains' option" do
|
319
|
-
html = Govspeak::Document.new("[internal link](http://www.not-external-either.com)", document_domains: %w
|
317
|
+
html = Govspeak::Document.new("[internal link](http://www.not-external-either.com)", document_domains: %w[www.not-external.com www.not-external-either.com]).to_html
|
320
318
|
refute html.include?('rel="external"'), "should not consider www.not-external-either.com as an external url"
|
321
319
|
end
|
322
320
|
|
@@ -338,17 +336,17 @@ Teston
|
|
338
336
|
test "should treat a mailto as internal" do
|
339
337
|
html = Govspeak::Document.new("[link](mailto:a@b.com)").to_html
|
340
338
|
refute html.include?('rel="external"')
|
341
|
-
assert_equal %
|
339
|
+
assert_equal %(<p><a href="mailto:a@b.com">link</a></p>\n), deobfuscate_mailto(html)
|
342
340
|
end
|
343
341
|
|
344
342
|
test "permits mailto:// URI" do
|
345
343
|
html = Govspeak::Document.new("[link](mailto://a@b.com)").to_html
|
346
|
-
assert_equal %
|
344
|
+
assert_equal %(<p><a rel="external" href="mailto://a@b.com">link</a></p>\n), deobfuscate_mailto(html)
|
347
345
|
end
|
348
346
|
|
349
347
|
test "permits dud mailto: URI" do
|
350
348
|
html = Govspeak::Document.new("[link](mailto:)").to_html
|
351
|
-
assert_equal %
|
349
|
+
assert_equal %(<p><a href="mailto:">link</a></p>\n), deobfuscate_mailto(html)
|
352
350
|
end
|
353
351
|
|
354
352
|
test "permits trailing whitespace in an URI" do
|
@@ -360,7 +358,7 @@ Teston
|
|
360
358
|
# TODO: review whether we should require closing symbols for these extensions
|
361
359
|
# need to check all existing content.
|
362
360
|
test_given_govspeak "xaa" do
|
363
|
-
assert_html_output
|
361
|
+
assert_html_output "<p>xaa</p>"
|
364
362
|
assert_text_output "xaa"
|
365
363
|
end
|
366
364
|
|
@@ -368,18 +366,18 @@ Teston
|
|
368
366
|
$!
|
369
367
|
rainbow
|
370
368
|
$!" do
|
371
|
-
assert_html_output %
|
369
|
+
assert_html_output %(
|
372
370
|
<div class="summary">
|
373
371
|
<p>rainbow</p>
|
374
|
-
</div>
|
372
|
+
</div>)
|
375
373
|
assert_text_output "rainbow"
|
376
374
|
end
|
377
375
|
|
378
376
|
test_given_govspeak "$C help, send cake $C" do
|
379
|
-
assert_html_output %
|
377
|
+
assert_html_output %(
|
380
378
|
<div class="contact">
|
381
379
|
<p>help, send cake</p>
|
382
|
-
</div>
|
380
|
+
</div>)
|
383
381
|
assert_text_output "help, send cake"
|
384
382
|
end
|
385
383
|
|
@@ -388,10 +386,10 @@ Teston
|
|
388
386
|
street
|
389
387
|
road
|
390
388
|
$A" do
|
391
|
-
assert_html_output %
|
389
|
+
assert_html_output %(
|
392
390
|
<div class="address"><div class="adr org fn"><p>
|
393
391
|
street<br>road<br>
|
394
|
-
</p></div></div>
|
392
|
+
</p></div></div>)
|
395
393
|
assert_text_output "street road"
|
396
394
|
end
|
397
395
|
|
@@ -401,7 +399,7 @@ Teston
|
|
401
399
|
help
|
402
400
|
$I
|
403
401
|
$P" do
|
404
|
-
assert_html_output %
|
402
|
+
assert_html_output %(<div class="place">\n\n<div class="information">\n<p>help</p>\n</div>\n</div>)
|
405
403
|
assert_text_output "help"
|
406
404
|
end
|
407
405
|
|
@@ -409,10 +407,10 @@ Teston
|
|
409
407
|
$D
|
410
408
|
can you tell me how to get to...
|
411
409
|
$D" do
|
412
|
-
assert_html_output %
|
410
|
+
assert_html_output %(
|
413
411
|
<div class="form-download">
|
414
412
|
<p>can you tell me how to get to…</p>
|
415
|
-
</div>
|
413
|
+
</div>)
|
416
414
|
assert_text_output "can you tell me how to get to…"
|
417
415
|
end
|
418
416
|
|
@@ -420,10 +418,10 @@ Teston
|
|
420
418
|
$CTA
|
421
419
|
Click here to start the tool
|
422
420
|
$CTA" do
|
423
|
-
assert_html_output %
|
421
|
+
assert_html_output %(
|
424
422
|
<div class="call-to-action">
|
425
423
|
<p>Click here to start the tool</p>
|
426
|
-
</div>
|
424
|
+
</div>)
|
427
425
|
assert_text_output "Click here to start the tool"
|
428
426
|
end
|
429
427
|
|
@@ -434,12 +432,12 @@ Teston
|
|
434
432
|
Click here to start the tool
|
435
433
|
$CTA
|
436
434
|
" do
|
437
|
-
assert_html_output %
|
435
|
+
assert_html_output %(
|
438
436
|
<p>Here is some text</p>
|
439
437
|
|
440
438
|
<div class="call-to-action">
|
441
439
|
<p>Click here to start the tool</p>
|
442
|
-
</div>
|
440
|
+
</div>)
|
443
441
|
end
|
444
442
|
|
445
443
|
test_given_govspeak "
|
@@ -447,13 +445,13 @@ Teston
|
|
447
445
|
|
448
446
|
$CTA
|
449
447
|
Click here to start the tool
|
450
|
-
$CTA", document_domains: %w
|
451
|
-
assert_html_output %
|
448
|
+
$CTA", document_domains: %w[www.not-external.com] do
|
449
|
+
assert_html_output %(
|
452
450
|
<p><a href="http://www.not-external.com">internal link</a></p>
|
453
451
|
|
454
452
|
<div class="call-to-action">
|
455
453
|
<p>Click here to start the tool</p>
|
456
|
-
</div>
|
454
|
+
</div>)
|
457
455
|
end
|
458
456
|
|
459
457
|
test_given_govspeak "
|
@@ -469,7 +467,7 @@ Teston
|
|
469
467
|
s2. bungle
|
470
468
|
s3. george
|
471
469
|
" do
|
472
|
-
assert_html_output %
|
470
|
+
assert_html_output %(
|
473
471
|
<ol class="steps">
|
474
472
|
<li>
|
475
473
|
<p>zippy</p>
|
@@ -480,7 +478,7 @@ Teston
|
|
480
478
|
<li>
|
481
479
|
<p>george</p>
|
482
480
|
</li>
|
483
|
-
</ol>
|
481
|
+
</ol>)
|
484
482
|
assert_text_output "zippy bungle george"
|
485
483
|
end
|
486
484
|
|
@@ -491,7 +489,7 @@ Teston
|
|
491
489
|
s1. step
|
492
490
|
s2. list
|
493
491
|
" do
|
494
|
-
assert_html_output %
|
492
|
+
assert_html_output %(
|
495
493
|
<ul>
|
496
494
|
<li>unordered</li>
|
497
495
|
<li>list</li>
|
@@ -504,7 +502,7 @@ Teston
|
|
504
502
|
<li>
|
505
503
|
<p>list</p>
|
506
504
|
</li>
|
507
|
-
</ol>
|
505
|
+
</ol>)
|
508
506
|
assert_text_output "unordered list step list"
|
509
507
|
end
|
510
508
|
|
@@ -592,31 +590,31 @@ Teston
|
|
592
590
|
* 1. jumps over the lazy dog
|
593
591
|
$EndLegislativeList
|
594
592
|
" do
|
595
|
-
assert_html_output %
|
593
|
+
assert_html_output %(
|
596
594
|
<p>The quick brown fox</p>
|
597
595
|
|
598
596
|
<ol class="legislative-list">
|
599
597
|
<li>1. jumps over the lazy dog</li>
|
600
598
|
</ol>
|
601
|
-
|
599
|
+
)
|
602
600
|
end
|
603
601
|
|
604
602
|
test_given_govspeak "This bit of text\r\n\r\n$LegislativeList\r\n* 1. should be turned into a list\r\n$EndLegislativeList" do
|
605
|
-
assert_html_output %
|
603
|
+
assert_html_output %(
|
606
604
|
<p>This bit of text</p>
|
607
605
|
|
608
606
|
<ol class="legislative-list">
|
609
607
|
<li>1. should be turned into a list</li>
|
610
608
|
</ol>
|
611
|
-
|
609
|
+
)
|
612
610
|
end
|
613
611
|
|
614
612
|
test_given_govspeak "
|
615
613
|
Zippy, Bungle and George did not qualify for the tax exemption in s428. They filled in their tax return accordingly.
|
616
614
|
" do
|
617
|
-
assert_html_output %
|
615
|
+
assert_html_output %(
|
618
616
|
<p>Zippy, Bungle and George did not qualify for the tax exemption in s428. They filled in their tax return accordingly.</p>
|
619
|
-
|
617
|
+
)
|
620
618
|
end
|
621
619
|
|
622
620
|
test_given_govspeak ":scotland: I am very devolved\n and very scottish \n:scotland:" do
|
@@ -632,19 +630,19 @@ Teston
|
|
632
630
|
end
|
633
631
|
|
634
632
|
test_given_govspeak "@ Message with [a link](http://foo.bar/)@" do
|
635
|
-
assert_html_output %
|
633
|
+
assert_html_output %(
|
636
634
|
<div role="note" aria-label="Important" class="advisory">
|
637
635
|
<p><strong>Message with <a rel="external" href="http://foo.bar/">a link</a></strong></p>
|
638
636
|
</div>
|
639
|
-
|
637
|
+
)
|
640
638
|
end
|
641
639
|
|
642
|
-
test
|
640
|
+
test "sanitize source input by default" do
|
643
641
|
document = Govspeak::Document.new("<script>doBadThings();</script>")
|
644
642
|
assert_equal "", document.to_html.strip
|
645
643
|
end
|
646
644
|
|
647
|
-
test
|
645
|
+
test "it can have sanitizing disabled" do
|
648
646
|
document = Govspeak::Document.new("<script>doGoodThings();</script>", sanitize: false)
|
649
647
|
assert_equal "<script>doGoodThings();</script>", document.to_html.strip
|
650
648
|
end
|
@@ -659,7 +657,7 @@ Teston
|
|
659
657
|
assert document.valid?
|
660
658
|
end
|
661
659
|
|
662
|
-
expected_priority_list_output =
|
660
|
+
expected_priority_list_output = %(
|
663
661
|
<ul>
|
664
662
|
<li class="primary-item">List item 1</li>
|
665
663
|
<li class="primary-item">List item 2</li>
|
@@ -667,7 +665,7 @@ Teston
|
|
667
665
|
<li>List item 4</li>
|
668
666
|
<li>List item 5</li>
|
669
667
|
</ul>
|
670
|
-
|
668
|
+
)
|
671
669
|
|
672
670
|
test "Single priority list ending with EOF" do
|
673
671
|
govspeak = "$PriorityList:3
|
@@ -713,7 +711,6 @@ Teston
|
|
713
711
|
end
|
714
712
|
end
|
715
713
|
|
716
|
-
|
717
714
|
test "Multiple priority lists" do
|
718
715
|
govspeak = "
|
719
716
|
$PriorityList:3
|
@@ -728,7 +725,7 @@ $PriorityList:1
|
|
728
725
|
* List item 2"
|
729
726
|
|
730
727
|
given_govspeak(govspeak) do
|
731
|
-
assert_html_output
|
728
|
+
assert_html_output %(
|
732
729
|
<ul>
|
733
730
|
<li class="primary-item">List item 1</li>
|
734
731
|
<li class="primary-item">List item 2</li>
|
@@ -741,7 +738,7 @@ $PriorityList:1
|
|
741
738
|
<li class="primary-item">List item 1</li>
|
742
739
|
<li>List item 2</li>
|
743
740
|
</ul>
|
744
|
-
|
741
|
+
)
|
745
742
|
end
|
746
743
|
end
|
747
744
|
|
@@ -779,7 +776,7 @@ $PriorityList:1
|
|
779
776
|
* List item 5"
|
780
777
|
|
781
778
|
given_govspeak(govspeak) do
|
782
|
-
assert_html_output
|
779
|
+
assert_html_output %(
|
783
780
|
<p>This is a paragraph</p>
|
784
781
|
|
785
782
|
<ul>
|
@@ -789,20 +786,20 @@ $PriorityList:1
|
|
789
786
|
<li>List item 4</li>
|
790
787
|
<li>List item 5</li>
|
791
788
|
</ul>
|
792
|
-
|
789
|
+
)
|
793
790
|
end
|
794
791
|
end
|
795
792
|
|
796
793
|
test "should remove quotes surrounding a blockquote" do
|
797
|
-
govspeak = %
|
794
|
+
govspeak = %(
|
798
795
|
He said:
|
799
796
|
|
800
797
|
> "I'm not sure what you mean!"
|
801
798
|
|
802
|
-
Or so we thought.
|
799
|
+
Or so we thought.)
|
803
800
|
|
804
801
|
given_govspeak(govspeak) do
|
805
|
-
assert_html_output
|
802
|
+
assert_html_output %(
|
806
803
|
<p>He said:</p>
|
807
804
|
|
808
805
|
<blockquote>
|
@@ -810,7 +807,7 @@ Or so we thought.}
|
|
810
807
|
</blockquote>
|
811
808
|
|
812
809
|
<p>Or so we thought.</p>
|
813
|
-
|
810
|
+
)
|
814
811
|
end
|
815
812
|
end
|
816
813
|
|
@@ -821,13 +818,13 @@ Or so we thought.}
|
|
821
818
|
> last line"
|
822
819
|
|
823
820
|
given_govspeak(govspeak) do
|
824
|
-
assert_html_output
|
821
|
+
assert_html_output %(
|
825
822
|
<blockquote>
|
826
823
|
<p>first line</p>
|
827
824
|
|
828
825
|
<p class="last-child">last line</p>
|
829
826
|
</blockquote>
|
830
|
-
|
827
|
+
)
|
831
828
|
end
|
832
829
|
end
|
833
830
|
end
|