govspeak 6.5.3 → 6.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Rakefile +6 -3
- data/lib/govspeak.rb +54 -52
- data/lib/govspeak/html_sanitizer.rb +3 -3
- data/lib/govspeak/kramdown_overrides.rb +2 -2
- data/lib/govspeak/link_extractor.rb +3 -3
- data/lib/govspeak/post_processor.rb +17 -5
- data/lib/govspeak/presenters/attachment_presenter.rb +26 -26
- data/lib/govspeak/presenters/image_presenter.rb +2 -2
- data/lib/govspeak/structured_header_extractor.rb +2 -2
- data/lib/govspeak/version.rb +1 -1
- data/lib/kramdown/parser/govuk.rb +4 -5
- data/test/blockquote_extra_quote_remover_test.rb +25 -27
- data/test/govspeak_attachment_link_test.rb +0 -2
- data/test/govspeak_attachment_test.rb +0 -2
- data/test/govspeak_attachments_image_test.rb +2 -4
- data/test/govspeak_attachments_inline_test.rb +4 -6
- data/test/govspeak_button_test.rb +8 -10
- data/test/govspeak_contacts_test.rb +11 -13
- data/test/govspeak_extract_contact_content_ids_test.rb +0 -2
- data/test/govspeak_footnote_test.rb +31 -0
- data/test/govspeak_images_bang_test.rb +30 -32
- data/test/govspeak_images_test.rb +36 -38
- data/test/govspeak_link_extractor_test.rb +1 -1
- data/test/govspeak_link_test.rb +0 -2
- data/test/govspeak_structured_headers_test.rb +5 -4
- data/test/govspeak_table_with_headers_test.rb +67 -20
- data/test/govspeak_test.rb +80 -83
- data/test/govspeak_test_helper.rb +1 -1
- data/test/html_sanitizer_test.rb +0 -1
- data/test/presenters/h_card_presenter_test.rb +0 -2
- data/test/test_helper.rb +6 -2
- metadata +48 -34
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class BlockquoteExtraQuoteRemoverTest < Minitest::Test
|
@@ -14,85 +12,85 @@ class BlockquoteExtraQuoteRemoverTest < Minitest::Test
|
|
14
12
|
end
|
15
13
|
|
16
14
|
test "ignores nil" do
|
17
|
-
|
15
|
+
assert_nil Govspeak::BlockquoteExtraQuoteRemover.remove(nil)
|
18
16
|
end
|
19
17
|
|
20
18
|
test "ignores text without double quotes" do
|
21
|
-
assert_leaves_untouched %
|
19
|
+
assert_leaves_untouched %(no quotes\na few lines,\n\n\n\nbut no quotes\n\n)
|
22
20
|
end
|
23
21
|
|
24
22
|
test "ignores text without a quote symbol" do
|
25
|
-
assert_leaves_untouched %
|
23
|
+
assert_leaves_untouched %(quotes\n"but not with a > symbol")
|
26
24
|
end
|
27
25
|
|
28
26
|
test "transforms text with surrounding quotes" do
|
29
27
|
assert_remover_transforms(
|
30
|
-
%
|
31
|
-
%
|
28
|
+
%(He said:\n> "yes, it's true!"\n\napparently.) =>
|
29
|
+
%(He said:\n> yes, it's true!\n\napparently.),
|
32
30
|
)
|
33
31
|
end
|
34
32
|
|
35
33
|
test "leaves quotes in the middle of the string" do
|
36
34
|
assert_remover_transforms(
|
37
|
-
%
|
38
|
-
%
|
35
|
+
%(He said:\n> "yes, it's true!" whilst sipping a cocktail. "And yes, I did rather enjoy it." \n\napparently.) =>
|
36
|
+
%(He said:\n> yes, it's true!" whilst sipping a cocktail. "And yes, I did rather enjoy it.\n\napparently.),
|
39
37
|
)
|
40
38
|
end
|
41
39
|
|
42
40
|
test "leaves trailing text and quote intact" do
|
43
41
|
assert_remover_transforms(
|
44
|
-
%
|
45
|
-
%
|
42
|
+
%(He said:\n> "yes, it's true!" whilst sipping a cocktail.) =>
|
43
|
+
%(He said:\n> yes, it's true!" whilst sipping a cocktail.),
|
46
44
|
)
|
47
45
|
end
|
48
46
|
|
49
47
|
test "windows line breaks" do
|
50
48
|
assert_remover_transforms(
|
51
|
-
%
|
52
|
-
%
|
49
|
+
%(Sir George Young MP, said\r\n> "I welcome the positive public response to the e-petitions site, which is important way of building a bridge between people and Parliament.”\r\n## The special relationship) =>
|
50
|
+
%(Sir George Young MP, said\r\n> I welcome the positive public response to the e-petitions site, which is important way of building a bridge between people and Parliament.\r\n## The special relationship),
|
53
51
|
)
|
54
52
|
end
|
55
53
|
|
56
54
|
test "no space in front" do
|
57
55
|
assert_remover_transforms(
|
58
|
-
%
|
59
|
-
%
|
56
|
+
%(>"As we continue with the redundancy process we will ensure we retain the capabilities that our armed forces will require to meet the challenges of the future. The redundancy programme will not impact adversely on the current operations in Afghanistan, where our armed forces continue to fight so bravely on this country's behalf.") =>
|
57
|
+
%(> As we continue with the redundancy process we will ensure we retain the capabilities that our armed forces will require to meet the challenges of the future. The redundancy programme will not impact adversely on the current operations in Afghanistan, where our armed forces continue to fight so bravely on this country's behalf.),
|
60
58
|
)
|
61
59
|
end
|
62
60
|
|
63
61
|
test "handles space after a quote" do
|
64
62
|
assert_remover_transforms(
|
65
|
-
%
|
66
|
-
%
|
63
|
+
%(>" Test") =>
|
64
|
+
%(> Test),
|
67
65
|
)
|
68
66
|
end
|
69
67
|
|
70
68
|
test "remove double double quotes" do
|
71
69
|
assert_remover_transforms(
|
72
|
-
%
|
73
|
-
%
|
70
|
+
%(We heard it said:\n\n> ""Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners."") =>
|
71
|
+
%(We heard it said:\n\n> Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners.),
|
74
72
|
)
|
75
73
|
assert_remover_transforms(
|
76
|
-
%
|
77
|
-
%
|
74
|
+
%(> ""Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners.) =>
|
75
|
+
%(> Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners.),
|
78
76
|
)
|
79
77
|
end
|
80
78
|
|
81
79
|
test "removes quotes correctly from multi-line blockquotes" do
|
82
80
|
assert_remover_transforms(
|
83
|
-
%
|
84
|
-
%
|
81
|
+
%(> "Here is a block quote using 2 lines and two of the arrows.\n> I am not sure how this will render. I think it will mash them together.") =>
|
82
|
+
%(> Here is a block quote using 2 lines and two of the arrows.\n> I am not sure how this will render. I think it will mash them together.),
|
85
83
|
)
|
86
84
|
end
|
87
85
|
|
88
86
|
test "preserves multiline blockquotes with plain newlines quotes" do
|
89
87
|
assert_remover_transforms(
|
90
|
-
%
|
91
|
-
%
|
92
|
-
|
88
|
+
%(> "line 1\n> \n> "line 2\n> \n> "line 3") =>
|
89
|
+
%(> line 1\n> \n> line 2\n> \n> line 3),
|
90
|
+
)
|
93
91
|
end
|
94
92
|
|
95
93
|
test "preserve newlines when there's a blockquote with additional text after" do
|
96
|
-
assert_leaves_untouched(%
|
94
|
+
assert_leaves_untouched(%(> \n> blah))
|
97
95
|
end
|
98
96
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class GovspeakAttachmentsImageTest < Minitest::Test
|
@@ -77,11 +75,11 @@ class GovspeakAttachmentsImageTest < Minitest::Test
|
|
77
75
|
"[embed:attachments:image:1fe8]",
|
78
76
|
[build_attachment(id: 10, url: "http://a.b/c.jpg", title: "My Title", content_id: "1fe8")],
|
79
77
|
)
|
80
|
-
expected_html_output = %
|
78
|
+
expected_html_output = %(
|
81
79
|
<figure id="attachment_10" class="image embedded">
|
82
80
|
<div class="img"><img src="http://a.b/c.jpg" alt="My Title"></div>
|
83
81
|
</figure>
|
84
|
-
|
82
|
+
)
|
85
83
|
assert_match(compress_html(expected_html_output), compress_html(rendered))
|
86
84
|
end
|
87
85
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class GovspeakAttachmentsInlineTest < Minitest::Test
|
@@ -141,10 +139,10 @@ class GovspeakAttachmentsInlineTest < Minitest::Test
|
|
141
139
|
number_of_pages: 2,
|
142
140
|
)],
|
143
141
|
)
|
144
|
-
link = %
|
145
|
-
type = %
|
146
|
-
file_size = %
|
147
|
-
pages = %
|
142
|
+
link = %(<a href="#{Regexp.quote('http://a.b/test.txt')}">My Attached Text File</a>)
|
143
|
+
type = %(<span class="type">Plain text</span>)
|
144
|
+
file_size = %(<span class="file-size">2 KB</span>)
|
145
|
+
pages = %(<span class="page-length">2 pages</span>)
|
148
146
|
assert_match(/#{link}\s+\(#{type}, #{file_size}, #{pages}\)/, rendered)
|
149
147
|
end
|
150
148
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
require "govspeak_test_helper"
|
5
3
|
|
@@ -46,13 +44,13 @@ class GovspeakTest < Minitest::Test
|
|
46
44
|
end
|
47
45
|
|
48
46
|
test_given_govspeak "Text before the button with line breaks \n\n\n{button}[Start Now](http://www.gov.uk){/button}\n\n\n test after the button" do
|
49
|
-
assert_html_output %
|
47
|
+
assert_html_output %(
|
50
48
|
<p>Text before the button with line breaks</p>
|
51
49
|
|
52
50
|
<p><a class="gem-c-button govuk-button" role="button" href="http://www.gov.uk">Start Now</a></p>
|
53
51
|
|
54
52
|
<p>test after the button</p>
|
55
|
-
|
53
|
+
)
|
56
54
|
assert_text_output "Text before the button with line breaks Start Now test after the button"
|
57
55
|
end
|
58
56
|
|
@@ -82,23 +80,23 @@ class GovspeakTest < Minitest::Test
|
|
82
80
|
|
83
81
|
# Make sure button renders when typical linebreaks are before it, seen in publishing applications
|
84
82
|
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 %
|
83
|
+
assert_html_output %(
|
86
84
|
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Line breaks</a></p>
|
87
85
|
|
88
86
|
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
89
87
|
|
90
88
|
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
91
|
-
|
89
|
+
)
|
92
90
|
end
|
93
91
|
|
94
92
|
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 %
|
93
|
+
assert_html_output %(
|
96
94
|
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">More line breaks</a></p>
|
97
95
|
|
98
96
|
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
99
97
|
|
100
98
|
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
101
|
-
|
99
|
+
)
|
102
100
|
end
|
103
101
|
|
104
102
|
test_given_govspeak %{
|
@@ -114,7 +112,7 @@ class GovspeakTest < Minitest::Test
|
|
114
112
|
lorem lorem lorem
|
115
113
|
lorem lorem lorem
|
116
114
|
} do
|
117
|
-
assert_html_output %
|
115
|
+
assert_html_output %(
|
118
116
|
<h2 id="register-to-vote">Register to vote</h2>
|
119
117
|
|
120
118
|
<p>Introduction text about the service.</p>
|
@@ -126,6 +124,6 @@ class GovspeakTest < Minitest::Test
|
|
126
124
|
|
127
125
|
<p>lorem lorem lorem
|
128
126
|
lorem lorem lorem</p>
|
129
|
-
|
127
|
+
)
|
130
128
|
end
|
131
129
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class GovspeakContactsTest < Minitest::Test
|
@@ -61,7 +59,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
61
59
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
62
60
|
|
63
61
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
64
|
-
expected_html_output = %
|
62
|
+
expected_html_output = %(
|
65
63
|
<div id="contact_4f3383e4-48a2-4461-a41d-f85ea8b89ba0" class="contact postal-address">
|
66
64
|
<div class="content">
|
67
65
|
<h3>Government Digital Service</h3>
|
@@ -89,7 +87,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
89
87
|
</div>
|
90
88
|
</div>
|
91
89
|
</div>
|
92
|
-
|
90
|
+
)
|
93
91
|
|
94
92
|
assert_equal(compress_html(expected_html_output), compress_html(rendered))
|
95
93
|
end
|
@@ -105,7 +103,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
105
103
|
contact = build_contact(post_addresses: [])
|
106
104
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
107
105
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
108
|
-
expected_html_output = %
|
106
|
+
expected_html_output = %(
|
109
107
|
<div id="contact_4f3383e4-48a2-4461-a41d-f85ea8b89ba0" class="contact">
|
110
108
|
<div class="content">
|
111
109
|
<h3>Government Digital Service</h3>
|
@@ -127,7 +125,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
127
125
|
</div>
|
128
126
|
</div>
|
129
127
|
</div>
|
130
|
-
|
128
|
+
)
|
131
129
|
assert_equal(compress_html(expected_html_output), compress_html(rendered))
|
132
130
|
end
|
133
131
|
|
@@ -140,11 +138,11 @@ class GovspeakContactsTest < Minitest::Test
|
|
140
138
|
])
|
141
139
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
142
140
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
143
|
-
expected = %
|
141
|
+
expected = %(
|
144
142
|
<p class="adr">
|
145
143
|
<span class="street-address">125 Kingsway</span>
|
146
144
|
</p>
|
147
|
-
|
145
|
+
)
|
148
146
|
assert_match(compress_html(expected), compress_html(rendered))
|
149
147
|
end
|
150
148
|
|
@@ -156,7 +154,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
156
154
|
])
|
157
155
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
158
156
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
159
|
-
refute_match(%
|
157
|
+
refute_match(%(<p class="adr">), compress_html(rendered))
|
160
158
|
end
|
161
159
|
|
162
160
|
test "contact with an empty email address is not rendered" do
|
@@ -167,7 +165,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
167
165
|
])
|
168
166
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
169
167
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
170
|
-
refute_match(%
|
168
|
+
refute_match(%(<p class="email">), compress_html(rendered))
|
171
169
|
end
|
172
170
|
|
173
171
|
test "contact with an empty contact form is not rendered" do
|
@@ -178,7 +176,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
178
176
|
])
|
179
177
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
180
178
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
181
|
-
refute_match(%
|
179
|
+
refute_match(%(<p class="contact_form_url">), compress_html(rendered))
|
182
180
|
end
|
183
181
|
|
184
182
|
test "contact with an empty phone number is not rendered" do
|
@@ -189,7 +187,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
189
187
|
])
|
190
188
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
191
189
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
192
|
-
refute_match(%
|
190
|
+
refute_match(%(<p class="tel">), compress_html(rendered))
|
193
191
|
end
|
194
192
|
|
195
193
|
test "it auto links text in the description" do
|
@@ -197,7 +195,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
197
195
|
|
198
196
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
199
197
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
200
|
-
assert_match(%
|
198
|
+
assert_match(%(<p class="comments">My description about <a href="https://www.gov.uk">https://www.gov.uk</a></p>),
|
201
199
|
compress_html(rendered))
|
202
200
|
end
|
203
201
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "govspeak_test_helper"
|
3
|
+
|
4
|
+
class GovspeakFootnoteTest < Minitest::Test
|
5
|
+
include GovspeakTestHelper
|
6
|
+
|
7
|
+
test_given_govspeak "
|
8
|
+
Footnotes can be added[^1].
|
9
|
+
|
10
|
+
[^1]: And then later defined.
|
11
|
+
|
12
|
+
Footnotes can be added too[^2].
|
13
|
+
|
14
|
+
[^2]: And then later defined too." do
|
15
|
+
assert_html_output '
|
16
|
+
<p>Footnotes can be added<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote">[footnote 1]</a></sup>.</p>
|
17
|
+
|
18
|
+
<p>Footnotes can be added too<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote">[footnote 2]</a></sup>.</p>
|
19
|
+
|
20
|
+
<div class="footnotes" role="doc-endnotes">
|
21
|
+
<ol>
|
22
|
+
<li id="fn:1" role="doc-endnote">
|
23
|
+
<p>And then later defined. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">[go to where this is referenced]</a></p>
|
24
|
+
</li>
|
25
|
+
<li id="fn:2" role="doc-endnote">
|
26
|
+
<p>And then later defined too. <a href="#fnref:2" class="reversefootnote" role="doc-backlink">[go to where this is referenced]</a></p>
|
27
|
+
</li>
|
28
|
+
</ol>
|
29
|
+
</div>'
|
30
|
+
end
|
31
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
require "govspeak_test_helper"
|
5
3
|
|
@@ -20,40 +18,40 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
20
18
|
test "!!n syntax renders an image in options[:images]" do
|
21
19
|
given_govspeak "!!1", images: [Image.new] do
|
22
20
|
assert_html_output(
|
23
|
-
%
|
24
|
-
%
|
25
|
-
%
|
21
|
+
%(<figure class="image embedded">) +
|
22
|
+
%(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
|
23
|
+
%(</figure>),
|
26
24
|
)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
28
|
test "!!n syntax escapes alt text" do
|
31
|
-
given_govspeak "!!1", images: [Image.new(alt_text: %
|
29
|
+
given_govspeak "!!1", images: [Image.new(alt_text: %(my alt '&"<>))] do
|
32
30
|
assert_html_output(
|
33
|
-
%
|
34
|
-
%
|
35
|
-
%
|
31
|
+
%(<figure class="image embedded">) +
|
32
|
+
%(<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&"<>"></div>) +
|
33
|
+
%(</figure>),
|
36
34
|
)
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
38
|
test "!!n syntax renders nothing if not found" do
|
41
39
|
doc = Govspeak::Document.new("!!1")
|
42
|
-
assert_equal %
|
40
|
+
assert_equal %(\n), doc.to_html
|
43
41
|
end
|
44
42
|
|
45
43
|
test "Image:image-id syntax renders nothing" do
|
46
44
|
doc = Govspeak::Document.new("[Image:another-id]", images: [Image.new])
|
47
|
-
assert_equal %
|
45
|
+
assert_equal %(\n), doc.to_html
|
48
46
|
end
|
49
47
|
|
50
48
|
test "!!n syntax adds image caption if given" do
|
51
49
|
given_govspeak "!!1", images: [Image.new(caption: "My Caption & so on")] do
|
52
50
|
assert_html_output(
|
53
|
-
%
|
54
|
-
%
|
55
|
-
%
|
56
|
-
%
|
51
|
+
%(<figure class="image embedded">) +
|
52
|
+
%(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
|
53
|
+
%(<figcaption><p>My Caption & so on</p></figcaption>) +
|
54
|
+
%(</figure>),
|
57
55
|
)
|
58
56
|
end
|
59
57
|
end
|
@@ -61,9 +59,9 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
61
59
|
test "!!n syntax ignores a blank caption" do
|
62
60
|
given_govspeak "!!1", images: [Image.new(caption: " ")] do
|
63
61
|
assert_html_output(
|
64
|
-
%
|
65
|
-
%
|
66
|
-
%
|
62
|
+
%(<figure class="image embedded">) +
|
63
|
+
%(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
|
64
|
+
%(</figure>),
|
67
65
|
)
|
68
66
|
end
|
69
67
|
end
|
@@ -71,10 +69,10 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
71
69
|
test "¡¡n syntax adds image credit if given" do
|
72
70
|
given_govspeak "!!1", images: [Image.new(credit: "My Credit & so on")] do
|
73
71
|
assert_html_output(
|
74
|
-
%
|
75
|
-
%
|
76
|
-
%
|
77
|
-
%
|
72
|
+
%(<figure class="image embedded">) +
|
73
|
+
%(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
|
74
|
+
%(<figcaption><p>Image credit: My Credit & so on</p></figcaption>) +
|
75
|
+
%(</figure>),
|
78
76
|
)
|
79
77
|
end
|
80
78
|
end
|
@@ -82,9 +80,9 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
82
80
|
test "!!n syntax ignores a blank credit" do
|
83
81
|
given_govspeak "!!1", images: [Image.new(credit: " ")] do
|
84
82
|
assert_html_output(
|
85
|
-
%
|
86
|
-
%
|
87
|
-
%
|
83
|
+
%(<figure class="image embedded">) +
|
84
|
+
%(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>) +
|
85
|
+
%(</figure>),
|
88
86
|
)
|
89
87
|
end
|
90
88
|
end
|
@@ -92,13 +90,13 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
92
90
|
test "!!n syntax adds image caption and credit if given" do
|
93
91
|
given_govspeak "!!1", images: [Image.new(caption: "My Caption & so on", credit: "My Credit & so on")] do
|
94
92
|
assert_html_output(
|
95
|
-
%
|
96
|
-
%
|
97
|
-
%
|
98
|
-
%
|
99
|
-
%
|
100
|
-
%
|
101
|
-
%
|
93
|
+
%(<figure class="image embedded">) +
|
94
|
+
%(<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n) +
|
95
|
+
%(<figcaption>) +
|
96
|
+
%(<p>My Caption & so on</p>\n) +
|
97
|
+
%(<p>Image credit: My Credit & so on</p>) +
|
98
|
+
%(</figcaption>) +
|
99
|
+
%(</figure>),
|
102
100
|
)
|
103
101
|
end
|
104
102
|
end
|