Repository navigation
fix(context): title Markdown and HTML documents by their h1 - #206
Merged
human0-bot[bot] merged 1 commit intoOct 27, 2026
Merged
Conversation
A document without a frontmatter title was named after its file, and its h1 was skipped, so neither the title nor the index had it. HTML pages kept their .html extension in the fallback. A document's only top-level h1 now names it (several h1s are a concatenation and keep the file name), without the permalink anchor HTML generators add, and the title is carried to every chunk of a split file.
🦋 Changeset detectedLatest commit: f65324e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Approved — Search results now use a page's single top-level heading as its title when frontmatter is absent. HTML fallback titles no longer include the file extension.
Changes behavior: no — This corrects the parser's existing h1-title intent and aligns with its test contract; frontmatter precedence and section content stay unchanged. No earlier review on this pull request; this is the first look.
This codebase is run by Human0.
Merged
JayOfTheKeyboard
added a commit
to JayOfTheKeyboard/JayOfTheKeyboard
that referenced
this pull request
Oct 27, 2026
…it#757 and rea#7226
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
parseMarkdowntakes a document's title from frontmatter, and otherwise from the file name:Many doc sets have no frontmatter title and put the page title in an
# h1instead. That h1 is then lost twice: it is not the title, and the h1 before the first##is skipped, so it is not in the content either.doc_titlehas a BM25 weight of 5 and is the first half of every result title (docTitle > sectionTitle), so results readjobs > Creating jobsorclass-apirequestcontext > ...instead of the page's name.HTML is hit on every page.
parseHtmlgoes through the same code,.htmlis not in the extension list, and turndown's# h1is skipped like any other. Every Python 3.14 page is titled after its file, extension included (logging-cookbook.html,3.3.html). The existing test "extracts h1 as doc title and h2 as section boundaries" never checks the doc title, which isapi.html.reStructuredText and AsciiDoc already use the document's top heading as the title (
= Title, or the first underlined heading).I built packages with
context addonmainand with this change and counted pages titled by their file name:Section titles and section content are identical to
mainin all nine packages. Onlydoc_titlechanges. Pages that stay on the file name have no Markdown h1 or several (for example Fastify'sReference/*.md, which open with an HTML<h1 align="center">Fastify</h1>banner and then##, and Python'sc-api/tuple.html, which has two h1s).Some titles before and after:
api/class-apirequestcontext.mdclass-apirequestcontextclass: APIRequestContextget-started/gel-existing.mdxgel-existingGet Started with Drizzle and Gel in existing projectGuides/Write-Plugin.mdWrite-PluginHow to write a good pluginhowto/logging-cookbook.htmllogging-cookbook.htmlLogging Cookbooklibrary/lzma.htmllzma.htmllzma — Compression using the LZMA algorithmEnd to end, the top three
searchresults forsend jobsin pg-boss areintroduction > Quick start,pubsub > Introduction,jobs > Creating jobs (part 3)onmain, andIntroduction > Quick start,Jobs > Creating jobs (part 3),Jobs > Cancelling, resuming, and retrying jobswith the fix.Fix
llms-full.txt, where the first page's name would mislabel the rest, so those keep the file name. Frontmatter still wins.sectionPermalinkrule handles, through a sharedisPermalinkText), a trailing attribute block ({#id}in Docusaurus and VitePress,{.unnumbered}or{-}in Pandoc), and doubled spaces left by removed inline HTML. Attribute blocks are only taken from plain text, so# Blocks: `{#each}`keeps its code..htmland.htm, in onefileTitlehelper that AsciiDoc and reStructuredText now share.The permalink is dropped from the title only, not from the content. Sphinx puts navigation before the h1, so the h1 is often inside the Introduction section. Dropping its permalink there would change that section's link ratio for the table-of-contents filter, the reason #175 left anchors outside
<h2>alone. I tried extending the turndown rule to<h1>: it changed the content of 651 Python sections and dropped 4. With this approach, section content is unchanged.Not changed
## Title {#id}keeps the{#id}in its section title, as before.<h1>that is not inside one of the removed elements counts as an h1. With the page's own h1 that makes two, so the page keeps its file name, as onmain.ParsedDoc.frontmatter.titleis still only the frontmatter's title.Test
build.test.ts:{#jobs-api}givesThe Jobs API. Two h1s keepllms-full, and frontmatter beats the h1.# Preface {.unnumbered}givesPreface, and# Blocks: `{#each}`givesBlocks: {#each}.docTitle(API Reference). Sphinx¶and Docusaurus zero-width permalinks are dropped from the title and left in the Introduction content. A page with no h1 is titleddict, notdict.html.package-builder.test.ts: a split concatenation with one h1 per chunk keepsllms-full. The existing split test's HTML expectation changes fromflat.htmltoflat.search.retrieval.test.ts: the two HTML fixtures' expected titles change fromsystemctl.html > User servicestosystemctl > User services(and the same forsystemd.service).On the parent commit 8 tests fail, for example
expected 'jobs' to be 'Jobs'andexpected 'api.html' to be 'API Reference'. With the fix they pass.I broke each part of the fix in turn, and each time a test went red:
llms-full)The Jobs API){#id}strippedPreface)Blocks: {#each}).htmlnot strippedValidation
vitest runinpackages/context: 18 files, 366 tests pass.biome ci --error-on-warnings: clean.tsc --noEmit -p tsconfig.build.json: clean.context addbuilds of nine doc sets onmainand on this branch..changeset/brave-lamps-glow.md(patch).