govspeak 7.1.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/govspeak/version.rb +1 -1
- data/lib/govspeak.rb +2 -2
- data/test/govspeak_attachment_test.rb +6 -1
- data/test/govspeak_images_bang_test.rb +26 -0
- data/test/govspeak_images_test.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b23cb6b80ef9b9d71a55b5cf0c1ffa1d33c3127ebac6290e7ed57de253439bd
|
4
|
+
data.tar.gz: 5bbe38f1188c1159d7af520b22dc2fc011e95256c53be222170081220c11fa64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e3cbc3237ad2b739ff8d984d35e040e1379e716791fb9ed7d789b4d4ca9ce6398a53cb8bf095df68af80257aa5d1e2659803857f88677073576685da65df60
|
7
|
+
data.tar.gz: 0f9dc64d2983ffa7c546d54f96c852500d92b2b01e2b48d163784b5d41a2a6e38202d8385665c264287b8035d0b8d96059a5fd0be7f065774d602b3caeefc84b
|
data/CHANGELOG.md
CHANGED
data/lib/govspeak/version.rb
CHANGED
data/lib/govspeak.rb
CHANGED
@@ -424,14 +424,14 @@ module Govspeak
|
|
424
424
|
renderer.render(contact: ContactPresenter.new(contact))
|
425
425
|
end
|
426
426
|
|
427
|
-
extension("Image",
|
427
|
+
extension("Image", /^\[Image:\s*(.*?)\s*\]/) do |image_id|
|
428
428
|
image = images.detect { |c| c.is_a?(Hash) && c[:id] == image_id }
|
429
429
|
next "" unless image
|
430
430
|
|
431
431
|
render_image(ImagePresenter.new(image))
|
432
432
|
end
|
433
433
|
|
434
|
-
extension("Attachment",
|
434
|
+
extension("Attachment", /^\[Attachment:\s*(.*?)\s*\]/) do |attachment_id|
|
435
435
|
next "" if attachments.none? { |a| a[:id] == attachment_id }
|
436
436
|
|
437
437
|
%(<govspeak-embed-attachment id="#{attachment_id}"></govspeak-embed-attachment>)
|
@@ -21,7 +21,7 @@ class GovspeakAttachmentTest < Minitest::Test
|
|
21
21
|
assert_match(/Attachment Title/, rendered)
|
22
22
|
end
|
23
23
|
|
24
|
-
test "only renders attachment when markdown extension starts on a line" do
|
24
|
+
test "only renders attachment when markdown extension starts on a new line" do
|
25
25
|
attachment = {
|
26
26
|
id: "attachment.pdf",
|
27
27
|
url: "http://example.com/attachment.pdf",
|
@@ -34,5 +34,10 @@ class GovspeakAttachmentTest < Minitest::Test
|
|
34
34
|
rendered = render_govspeak("[Attachment:attachment.pdf] some text", [attachment])
|
35
35
|
assert_match(/<section class="gem-c-attachment/, rendered)
|
36
36
|
assert_match(/<p>some text<\/p>/, rendered)
|
37
|
+
|
38
|
+
rendered = render_govspeak("some text\n[Attachment:attachment.pdf]\nsome more text", [attachment])
|
39
|
+
assert_match(/<p>some text<\/p>/, rendered)
|
40
|
+
assert_match(/<section class="gem-c-attachment/, rendered)
|
41
|
+
assert_match(/<p>some more text<\/p>/, rendered)
|
37
42
|
end
|
38
43
|
end
|
@@ -80,4 +80,30 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
80
80
|
)
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
test "!!n syntax must start on a new line" do
|
85
|
+
given_govspeak "some text !!1", images: [Image.new] do
|
86
|
+
assert_html_output("<p>some text !!1</p>")
|
87
|
+
end
|
88
|
+
|
89
|
+
given_govspeak "!!1", images: [Image.new] do
|
90
|
+
assert_html_output(
|
91
|
+
"<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>",
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
given_govspeak "!!1 some text", images: [Image.new] do
|
96
|
+
assert_html_output(
|
97
|
+
"<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>\n<p>some text</p>",
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
given_govspeak "some text\n!!1\nsome more text", images: [Image.new] do
|
102
|
+
assert_html_output <<~HTML
|
103
|
+
<p>some text</p>
|
104
|
+
<figure class="image embedded"><div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div></figure>
|
105
|
+
<p>some more text</p>
|
106
|
+
HTML
|
107
|
+
end
|
108
|
+
end
|
83
109
|
end
|
@@ -88,5 +88,13 @@ class GovspeakImagesTest < Minitest::Test
|
|
88
88
|
"<figure class=\"image embedded\"><div class=\"img\"><img src=\"http://example.com/image.jpg\" alt=\"my alt\"></div></figure>\n<p>some text</p>",
|
89
89
|
)
|
90
90
|
end
|
91
|
+
|
92
|
+
given_govspeak "some text\n[Image:image-id]\nsome more text", images: [build_image] do
|
93
|
+
assert_html_output <<~HTML
|
94
|
+
<p>some text</p>
|
95
|
+
<figure class="image embedded"><div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div></figure>
|
96
|
+
<p>some more text</p>
|
97
|
+
HTML
|
98
|
+
end
|
91
99
|
end
|
92
100
|
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.1.
|
4
|
+
version: 7.1.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: 2023-
|
11
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -327,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
327
|
- !ruby/object:Gem::Version
|
328
328
|
version: '0'
|
329
329
|
requirements: []
|
330
|
-
rubygems_version: 3.4.
|
330
|
+
rubygems_version: 3.4.13
|
331
331
|
signing_key:
|
332
332
|
specification_version: 4
|
333
333
|
summary: Markup language for single domain
|