diff --git a/lib/govspeak.rb b/lib/govspeak.rb
index ee8ed3ff..54c859b2 100644
--- a/lib/govspeak.rb
+++ b/lib/govspeak.rb
@@ -201,8 +201,11 @@ def insert_strong_inside_p(body, parser=Govspeak::Document)
attachment = attachments.detect { |a| a[:content_id].match(content_id) }
next "" unless attachment
attachment = AttachmentPresenter.new(attachment)
- content = File.read(__dir__ + '/templates/inline_attachment.html.erb')
- ERB.new(content).result(binding).gsub(/\n/, "")
+ span_id = attachment.id ? %{ id="attachment_#{attachment.id}"} : ""
+ # new lines inside our title cause problems with govspeak rendering as this is expected to be on one line.
+ link = attachment.link(attachment.title.gsub("\n", " "), attachment.url)
+ attributes = attachment.attachment_attributes.empty? ? "" : " (#{attachment.attachment_attributes})"
+ %{#{link}#{attributes}}
end
def render_image(url, alt_text, caption = nil)
diff --git a/test/govspeak_attachments_inline_test.rb b/test/govspeak_attachments_inline_test.rb
index 9fd7f02e..538e15b5 100644
--- a/test/govspeak_attachments_inline_test.rb
+++ b/test/govspeak_attachments_inline_test.rb
@@ -52,6 +52,14 @@ def render_govspeak(govspeak, attachments = [])
assert_match(%r{.*}, rendered)
+ end
+
test "will show HTML type (in brackets) if file_extension is specified as html" do
rendered = render_govspeak(
"[embed:attachments:inline:1fe8]",
@@ -121,7 +129,7 @@ def render_govspeak(govspeak, attachments = [])
type = %{Plain text}
file_size = %{2 KB}
pages = %{2 pages}
- assert_match(/#{link}\s*\(#{type}, #{file_size}, #{pages}\)/, rendered)
+ assert_match(/#{link}\s+\(#{type}, #{file_size}, #{pages}\)/, rendered)
end
test "can render two inline attachments on the same line" do