-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Search: support section titles inside header tags #9339
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ac70213
Search: index generic doctype
stsewd 8e7229e
Test
stsewd 9fd28a1
Use exc_info
stsewd 5f5793e
Updates from review
stsewd 08d7369
Merge branch 'main' into index-generic-doctype
stsewd 27b62f5
Merge branch 'main' into index-generic-doctype
stsewd defc159
Update docs
stsewd fd58784
Search: support section titles inside header tags
stsewd 3b7d3df
Test
stsewd 43896d1
Apply suggestions from code review
stsewd 0303e84
Merge branch 'main' into parser-support-header-tag
stsewd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,9 @@ Read the Docs makes use of ARIA_ roles and other heuristics in order to process | |
Main content node | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
The main content node should have a main role (or a ``main`` tag), and there should only be one per page. | ||
This node is the one that contains all the page content. Example: | ||
The main content should be inside a ``main`` tag or an element with the role ``main``, | ||
and there should only be one per page. | ||
This node is the one that contains all the page content to be indexed. Example: | ||
|
||
.. code-block:: html | ||
:emphasize-lines: 10-12 | ||
|
@@ -55,6 +56,51 @@ This node is the one that contains all the page content. Example: | |
</body> | ||
</html> | ||
|
||
If a main node isn't found, | ||
we try to infer the main node from the parent of the first section with a ``h1`` tag. | ||
Example: | ||
|
||
.. code-block:: html | ||
:emphasize-lines: 10-20 | ||
|
||
<html> | ||
<head> | ||
... | ||
</head> | ||
<body> | ||
<div> | ||
This content isn't processed | ||
</div> | ||
|
||
<div id="parent"> | ||
<h1>First title</h1> | ||
<p> | ||
The parent of the h1 title will | ||
be taken as the main node, | ||
this is the div tag. | ||
</p> | ||
|
||
<h2>Second title</h2> | ||
<p>More content</p> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
If a section title isn't found, we default to the ``body`` tag. | ||
Example: | ||
|
||
.. code-block:: html | ||
:emphasize-lines: 5-7 | ||
|
||
<html> | ||
<head> | ||
... | ||
</head> | ||
<body> | ||
<p>Content</p> | ||
</body> | ||
</html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 examples. |
||
|
||
Irrelevant content | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
|
@@ -87,12 +133,15 @@ Example: | |
Sections | ||
~~~~~~~~ | ||
|
||
Sections are ``h`` tags, and sections of the same level should be neighbors. | ||
Additionally, sections should have an unique ``id`` attribute per page (this is used to link to the section). | ||
All content below the section, till the new section will be indexed as part of the section. Example: | ||
Sections are composed of a title, and a content. | ||
A section title can be a ``h`` tag, or a ``header`` tag containing a ``h`` tag, | ||
the ``h`` tag or its parent can contain an ``id`` attribute, which will be used to link to the section. | ||
|
||
All content bellow the title, till a new section is found will be indexed as part of the section content. | ||
stsewd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Example: | ||
|
||
.. code-block:: html | ||
:emphasize-lines: 2-10 | ||
:emphasize-lines: 2-10, 12-17, 21-26 | ||
|
||
<div role="main"> | ||
<h1 id="section-title"> | ||
|
@@ -114,17 +163,17 @@ All content below the section, till the new section will be indexed as part of t | |
|
||
... | ||
|
||
<h1 id="neigbor-section"> | ||
This section is neighbor of "section-title" | ||
</h1> | ||
<header> | ||
<h1 id="3">This is also a valid section title</h1> | ||
</header> | ||
<p> | ||
... | ||
Thi is the content of the third section. | ||
</p> | ||
</div> | ||
|
||
Sections can be inside till two nested tags (and have nested sections), | ||
and its immediate parent can contain the ``id`` attribute. | ||
Note that the section content still needs to be below the ``h`` tag. Example: | ||
Sections can be contained in up to two nested tags, and can contain other sections (nested sections). | ||
Note that the section content still needs to be below the section title. | ||
Example: | ||
|
||
.. code-block:: html | ||
:emphasize-lines: 3-11,14-21 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.