diff --git a/lib/govspeak.rb b/lib/govspeak.rb
index 9fcaf9d8..632b1c2f 100644
--- a/lib/govspeak.rb
+++ b/lib/govspeak.rb
@@ -189,7 +189,7 @@ def insert_strong_inside_p(body, parser=Govspeak::Document)
end
end
- extension('attachment', /\[embed:attachments:([0-9a-f-]+)\]/) do |content_id, body|
+ extension('attachment', /\[embed:attachments:(?!inline:|image:)\s*(.*?)\s*\]/) do |content_id, body|
attachment = attachments.detect { |a| a[:content_id].match(content_id) }
next "" unless attachment
attachment = AttachmentPresenter.new(attachment)
@@ -197,7 +197,7 @@ def insert_strong_inside_p(body, parser=Govspeak::Document)
ERB.new(content).result(binding)
end
- extension('attachment inline', /\[embed:attachments:inline:([0-9a-f-]+)\]/) do |content_id|
+ extension('attachment inline', /\[embed:attachments:inline:\s*(.*?)\s*\]/) do |content_id|
attachment = attachments.detect { |a| a[:content_id].match(content_id) }
next "" unless attachment
attachment = AttachmentPresenter.new(attachment)
@@ -209,7 +209,7 @@ def insert_strong_inside_p(body, parser=Govspeak::Document)
%{#{link}#{attributes}}
end
- extension('attachment image', /\[embed:attachments:image:([0-9a-f-]+)\]/) do |content_id|
+ extension('attachment image', /\[embed:attachments:image:\s*(.*?)\s*\]/) do |content_id|
attachment = attachments.detect { |a| a[:content_id].match(content_id) }
next "" unless attachment
attachment = AttachmentPresenter.new(attachment)
@@ -299,7 +299,7 @@ def self.devolved_options
end
end
- extension('embed link', /\[embed:link:([0-9a-f-]+)\]/) do |content_id|
+ extension('embed link', /\[embed:link:\s*(.*?)\s*\]/) do |content_id|
link = links.detect { |l| l[:content_id].match(content_id) }
next "" unless link
if link[:url]
@@ -314,7 +314,7 @@ def render_hcard_address(contact)
end
private :render_hcard_address
- extension('Contact', /\[Contact:([0-9a-f-]+)\]/) do |content_id|
+ extension('Contact', /\[Contact:\s*(.*?)\s*\]/) do |content_id|
contact = contacts.detect { |c| c[:content_id].match(content_id) }
next "" unless contact
contact = ContactPresenter.new(contact)
diff --git a/test/govspeak_attachments_image_test.rb b/test/govspeak_attachments_image_test.rb
index f0b87130..28fbf0d2 100644
--- a/test/govspeak_attachments_image_test.rb
+++ b/test/govspeak_attachments_image_test.rb
@@ -21,7 +21,7 @@ def compress_html(html)
end
test "renders an empty string for an image attachment not found" do
- assert_match("", render_govspeak("[embed:attachments:image:1fe8]", [build_attachment]))
+ assert_equal("\n", render_govspeak("[embed:attachments:image:1fe8]", [build_attachment]))
end
test "wraps an attachment in a figure with the id if the id is present" do
@@ -40,6 +40,14 @@ def compress_html(html)
assert_match(/