From 2e040c3ff7046a90ae9687d5a5c1259687be5ff9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 8 Feb 2017 19:46:01 -0600 Subject: [PATCH] Correctly transform an anchor link to GFM when copying it --- app/assets/javascripts/copy_as_gfm.js.es6 | 3 +++ changelogs/unreleased/copy-as-gfm-anchor-link.yml | 4 ++++ spec/features/copy_as_gfm_spec.rb | 2 ++ 3 files changed, 9 insertions(+) create mode 100644 changelogs/unreleased/copy-as-gfm-anchor-link.yml diff --git a/app/assets/javascripts/copy_as_gfm.js.es6 b/app/assets/javascripts/copy_as_gfm.js.es6 index 2bfe57b4100..4bd537a6f28 100644 --- a/app/assets/javascripts/copy_as_gfm.js.es6 +++ b/app/assets/javascripts/copy_as_gfm.js.es6 @@ -91,6 +91,9 @@ require('./lib/utils/common_utils'); }, }, SanitizationFilter: { + 'a[name]:not([href]):empty'(el, text) { + return el.outerHTML; + }, 'dl'(el, text) { let lines = text.trim().split('\n'); // Add two spaces to the front of subsequent list items lines, diff --git a/changelogs/unreleased/copy-as-gfm-anchor-link.yml b/changelogs/unreleased/copy-as-gfm-anchor-link.yml new file mode 100644 index 00000000000..e159e60a7d7 --- /dev/null +++ b/changelogs/unreleased/copy-as-gfm-anchor-link.yml @@ -0,0 +1,4 @@ +--- +title: Correctly transform an anchor link to GFM when copying it +merge_request: +author: diff --git a/spec/features/copy_as_gfm_spec.rb b/spec/features/copy_as_gfm_spec.rb index f3a5b565122..fec86128d03 100644 --- a/spec/features/copy_as_gfm_spec.rb +++ b/spec/features/copy_as_gfm_spec.rb @@ -251,6 +251,8 @@ describe 'Copy as GFM', feature: true, js: true do 'SanitizationFilter', <<-GFM.strip_heredoc + + sub