Skip to content
Open
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
Prev Previous commit
Next Next commit
fix: ensure title is set correctly
Since `title` variable is already available in the HTML, use that and
hide it from view instead of trying to muck with the nodes during
transformation.

Signed-off-by: Mike Fiedler <[email protected]>
  • Loading branch information
miketheman committed Aug 22, 2025
commit d2f23be086f485e53ed43a06c173d3c9133761a9
6 changes: 1 addition & 5 deletions pep_sphinx_extensions/pep_processor/transforms/pep_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ def apply(self) -> None:

# Generate the title section node and its properties
title_nodes = _line_to_nodes(pep_title_string)
# TODO: Why doesn't the new attribute show up in the HTML output?
# This is needed to change the way the index entry titles are generated,
# but is currently getting ignored/removed somewhere in the stack.
pep_title_attributes = {"classes": ["page-title"], "data-pagefind-meta": "title"}
pep_title_node = nodes.section("", nodes.title("", "", *title_nodes, **pep_title_attributes), names=["pep-content"])
pep_title_node = nodes.section("", nodes.title("", "", *title_nodes, classes=["page-title"]), names=["pep-content"])

# Insert the title node as the root element, move children down
document_children = self.document.children
Expand Down
3 changes: 3 additions & 0 deletions pep_sphinx_extensions/pep_theme/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ <h1>Python Enhancement Proposals</h1>
</button>
</header>
<article data-pagefind-body>
{# Add pagefind meta for the title to improve search result display #}
<div data-pagefind-meta="title:{{ title }}" style="display:none;"></div>
{{ body }}
</article>
{%- if not pagename.startswith(("404", "numerical")) %}
Expand All @@ -70,6 +72,7 @@ <h2>Contents</h2>
<script src="/pagefind/pagefind-ui.js"></script>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
// Initialize pagefind for desktop sidebar
new PagefindUI({ element: "#search", showSubResults: true });
});
</script>
Expand Down
Loading