Commit 131a04d7 authored by Mike Greiling's avatar Mike Greiling

remove underscore from user-content id namespace

parent 19f174bc
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
// scroll to user-generated markdown anchor if we cannot find a match // scroll to user-generated markdown anchor if we cannot find a match
if (document.getElementById(hash) === null) { if (document.getElementById(hash) === null) {
var target = document.getElementById('user-content_' + hash); var target = document.getElementById('user-content-' + hash);
if (target && target.scrollIntoView) { if (target && target.scrollIntoView) {
target.scrollIntoView(true); target.scrollIntoView(true);
window.scrollBy(0, adjustment); window.scrollBy(0, adjustment);
......
...@@ -2,7 +2,7 @@ module SharedMarkdown ...@@ -2,7 +2,7 @@ module SharedMarkdown
include Spinach::DSL include Spinach::DSL
def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki") def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki")
node = find("#{parent} h#{level} a#user-content_#{id}") node = find("#{parent} h#{level} a#user-content-#{id}")
expect(node[:href]).to eq "##{id}" expect(node[:href]).to eq "##{id}"
# Work around a weird Capybara behavior where calling `parent` on a node # Work around a weird Capybara behavior where calling `parent` on a node
......
...@@ -36,7 +36,7 @@ module Banzai ...@@ -36,7 +36,7 @@ module Banzai
if header_content = node.children.first if header_content = node.children.first
# namespace detection will be automatically handled via javascript (see issue #22781) # namespace detection will be automatically handled via javascript (see issue #22781)
namespace = "user-content_" namespace = "user-content-"
href = "#{id}#{uniq}" href = "#{id}#{uniq}"
push_toc(href, text) push_toc(href, text)
header_content.add_previous_sibling(anchor_tag("#{namespace}#{href}", href)) header_content.add_previous_sibling(anchor_tag("#{namespace}#{href}", href))
......
...@@ -22,7 +22,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do ...@@ -22,7 +22,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
html = header(i, "Header #{i}") html = header(i, "Header #{i}")
doc = filter(html) doc = filter(html)
expect(doc.css("h#{i} a").first.attr('id')).to eq "user-content_header-#{i}" expect(doc.css("h#{i} a").first.attr('id')).to eq "user-content-header-#{i}"
end end
end end
...@@ -34,7 +34,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do ...@@ -34,7 +34,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
it 'has a namespaced id' do it 'has a namespaced id' do
doc = filter(header(1, 'Header')) doc = filter(header(1, 'Header'))
expect(doc.css('h1 a').first.attr('id')).to eq 'user-content_header' expect(doc.css('h1 a').first.attr('id')).to eq 'user-content-header'
end end
it 'links to the non-namespaced id' do it 'links to the non-namespaced id' do
...@@ -67,7 +67,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do ...@@ -67,7 +67,7 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
it 'supports Unicode' do it 'supports Unicode' do
doc = filter(header(1, '한글')) doc = filter(header(1, '한글'))
expect(doc.css('h1 a').first.attr('id')).to eq 'user-content_한글' expect(doc.css('h1 a').first.attr('id')).to eq 'user-content-한글'
expect(doc.css('h1 a').first.attr('href')).to eq '#한글' expect(doc.css('h1 a').first.attr('href')).to eq '#한글'
end end
end end
......
...@@ -38,9 +38,9 @@ module MarkdownMatchers ...@@ -38,9 +38,9 @@ module MarkdownMatchers
set_default_markdown_messages set_default_markdown_messages
match do |actual| match do |actual|
expect(actual).to have_selector('h1 a#user-content_gitlab-markdown') expect(actual).to have_selector('h1 a#user-content-gitlab-markdown')
expect(actual).to have_selector('h2 a#user-content_markdown') expect(actual).to have_selector('h2 a#user-content-markdown')
expect(actual).to have_selector('h3 a#user-content_autolinkfilter') expect(actual).to have_selector('h3 a#user-content-autolinkfilter')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment