Skip to content

[Bug]: docs search treats # comments inside fenced code blocks as section headings #826

Closed

Description

@jimhoyd

Runtime revision and environment

main after #817. Found by the agent working on #822, and confirmed by reading packages/core/src/docs-search.ts:102-106.

Minimal reproduction

sectionAt finds headings with /^#{1,6}[ \t]+(.+?)…$/gm across the whole document. So a # comment line inside a fenced code block (for example # or, in an existing site: in a shell example) counts as a heading.

Example: searching maxRecordsPerOwner in the store README reports the match under the section "or, in an existing site:", which comes from a shell comment. It should be the real Markdown section.

Expected: headings inside fenced code blocks (``` or ~~~) are ignored when choosing the section title and index for search excerpts.

Relevant output

Affects search_docs and the MCP docs search results for any document with shell or YAML comments in code blocks. Not measured beyond the store README example.


Generated by Claude Code

Activity

  1. added
    bug
    ai-first
    in-progress
    on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-firstbugin-progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions