Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use h1 for first heading on a page #3009

Merged
merged 17 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 1 addition & 127 deletions integtest/spec/single_book_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,133 +314,7 @@
end
end

context 'regarding the xpack tag' do
let(:edit_me) do
<<~HTML.strip
<a class="edit_me" rel="nofollow" title="Edit this page on GitHub" href="https://github.com/elastic/docs/edit/master/index.asciidoc">edit</a>
HTML
end
let(:xpack_tag) do
<<~HTML.strip
<a class="xpack_tag" href="/subscriptions"></a>
HTML
end
let(:rx) { %r{<#{h} class="title"><a id="#{id}"></a>(.+?)</#{h}>} }
let(:title_tag) do
return unless body

m = rx.match(body)
raise "Can't find title_tag with #{rx} in #{body}" unless m

m[1]
end
shared_examples 'xpack tag title' do |has_tag|
it 'contains the edit_me link' do
expect(title_tag).to include(edit_me)
end
if has_tag
it 'contains the xpack tag' do
expect(title_tag).to include(xpack_tag)
end
else
it "doesn't contain the xpack tag" do
expect(title_tag).not_to include(xpack_tag)
end
end
end
shared_examples 'part page titles' do |onpart|
page_context 'part.html' do
let(:h) { 'h1' }
let(:id) { 'part' }
include_examples 'xpack tag title', onpart
end
end
shared_examples 'chapter page titles' do |onchapter, onfloater, onsection|
page_context 'chapter.html' do
let(:h) { 'h2' }
context 'the chapter title' do
let(:id) { 'chapter' }
include_examples 'xpack tag title', onchapter
end
context 'the section title' do
let(:id) { 'section' }
include_examples 'xpack tag title', onsection
end
context 'the float title' do
let(:rx) { %r{<h2><a id="floater"></a>(.+?)</h2>} }
include_examples 'xpack tag title', onfloater
end
end
end

def self.xpack_tag_context(onpart, onchapter, onfloater, onsection,
hide_xpack)
convert_single_before_context do |src|
index = xpack_tag_test_asciidoc onpart, onchapter, onfloater, onsection,
hide_xpack
src.write 'index.asciidoc', index
end

include_examples 'part page titles',
onpart && !hide_xpack
include_examples 'chapter page titles', onchapter && !hide_xpack,
onfloater && !hide_xpack, onsection && !hide_xpack
end

def self.xpack_tag_test_asciidoc(onpart, onchapter, onfloater, onsection,
hide_xpack)
<<~ASCIIDOC
= Title

#{hide_xpack ? ':hide-xpack-tags: true' : ''}

#{onpart ? '[role="xpack"]' : ''}
[[part]]
= Part

#{onchapter ? '[role="xpack"]' : ''}
[[chapter]]
== Chapter

Chapter words.

[[floater]]
[float]
== #{onfloater ? '[xpack]#Floater#' : 'Floater'}

Floater words.

#{onsection ? '[role="xpack"]' : ''}
[[section]]
=== Section

Section words.
ASCIIDOC
end

context 'when not hiding xpack tags' do
context 'when the xpack role is on a part' do
xpack_tag_context true, false, false, false, false
end
context 'when the xpack role is on a chapter' do
xpack_tag_context false, true, false, false, false
end
context 'when the xpack role is on a floating title' do
xpack_tag_context false, false, true, false, false
end
context 'when the xpack role is on a section' do
xpack_tag_context false, false, false, true, false
end
context 'when the xpack role is on everything' do
xpack_tag_context true, true, true, true, false
end
end
context 'when hiding xpack tags' do
context 'when the xpack role is on everything' do
xpack_tag_context true, true, true, true, true
end
end
end
# Do we still need the xpack tag tests?
colleenmcginnis marked this conversation as resolved.
Show resolved Hide resolved

context 'for README.asciidoc' do
convert_single_before_context do |src|
Expand Down
2 changes: 1 addition & 1 deletion resources/asciidoctor/lib/chunker/breadcrumbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def generate_breadcrumbs(section)
result += "\n"
result += generate_breadcrumb_links(section, chev)
result += "\n"
result += <<~HTML.strip
result + <<~HTML.strip
</div>
HTML
end
Expand Down
Loading