From 827bb125b26db23817cb502a584a5ca6f4e6a759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 16 Oct 2023 00:29:47 +0200 Subject: [PATCH] Explicitly open markdown links in the same window We were already opening them in the same window because we were accidentall sanitizing the `target` attribute, but now we're making the point more explicit. --- lib/markdown_converter.rb | 2 +- spec/models/legislation/draft_version_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/markdown_converter.rb b/lib/markdown_converter.rb index 66ad2a701..b68fc523a 100644 --- a/lib/markdown_converter.rb +++ b/lib/markdown_converter.rb @@ -30,7 +30,7 @@ class MarkdownConverter { filter_html: false, hard_wrap: true, - link_attributes: { target: "_blank" } + link_attributes: {} } end diff --git a/spec/models/legislation/draft_version_spec.rb b/spec/models/legislation/draft_version_spec.rb index 58123c837..968824cf1 100644 --- a/spec/models/legislation/draft_version_spec.rb +++ b/spec/models/legislation/draft_version_spec.rb @@ -38,6 +38,12 @@ describe Legislation::DraftVersion do expect(legislation_draft_version.toc_html).to eq(toc_html) end + it "does not add a target attribute to links" do + legislation_draft_version.body = "A [link](/url)" + + expect(legislation_draft_version.body_html).to eq("

A link

\n") + end + def body_markdown <<~BODY_MARKDOWN # Title 1