Repository navigation
Description
Problem
A Word report opens with its table of contents on the first screen, and every entry in it is dead. Mammoth converts both halves of Word's internal navigation: w:bookmarkStart becomes an empty <a id="…"> at the target (mammoth.browser.js:466-469, installed dependency) and an internal hyperlink becomes <a href="#…">. But the Markdown step throws the target half away: Turndown drops empty anchors, and ui-packages/web/src/formats/docx.ts:167-188 adds rules for notes and table cells but none for bookmarks. Verified with the exact configuration convertDocxToMarkdown uses: <h2><a id="_Toc123"></a>Results</h2> converts to ## Results — id gone — while See <a href="#_Toc123">Section 5</a> survives as [Section 5](#_Toc123). The reader cannot mend it: headings get positional ids markdown-heading-N (ui-packages/web/src/features/reader/markdown-reader/heading-model.ts:38-39, applied at markdown-reader/index.tsx:158-167), and a #-href renders as a plain anchor (file-link.tsx:18-23, components/markdown.tsx:58-79) whose hash finds no element. So the TOC, "see Section 5" cross-references and figure references — the navigation a long report carries in its own text — all do nothing when clicked, in a reader that already jumps to headings fine from its outline (markdown-reader/index.tsx:182-190). PDFs got their internal links in #189; Word's are still born dead.
Proposal
- In
convertDocxToMarkdown's HTML post-processing (docx.ts:160-165, alongside the existing table and comment passes), keep each bookmark target: carry the empty anchor's id onto the heading or paragraph it stands in, so the id survives Turndown in an element the reader anchors. - Make the reader follow a
#-href that names an id in the same document: scroll the reading pane to that element, as the outline'sscrollIntoViewalready does (markdown-reader/index.tsx:182-190). - A bookmark whose target is gone (deleted section) renders as the plain text it already falls back to — no broken link left pointing nowhere silently.
Goal
After this, a converted Word document navigates like the document its author wrote: clicking a table-of-contents entry or a cross-reference scrolls to its section, the same jump the outline performs, and no internal link in a Word file is dead on arrival.
Verification
grep -q "bookmark" ui-packages/web/src/formats/docx.ts
pnpm --filter @gamma-reader/web test --silent
pnpm checkRefs
- ui-packages/web/src/formats/docx.ts:160-165,167-188 — the post-processing passes and Turndown rules; none keep a bookmark's id
- ui-packages/web/node_modules/mammoth/mammoth.browser.js:466-469 — bookmarkStart →
<a id="…">; the target Mammoth hands over - ui-packages/web/src/features/reader/markdown-reader/heading-model.ts:38-39, index.tsx:158-167 — positional heading ids a
_Tocanchor can never match - ui-packages/web/src/features/reader/markdown-reader/file-link.tsx:18-23, ui-packages/web/src/components/markdown.tsx:58-79 — a
#-href becomes a plain anchor to a nonexistent id - ui-packages/web/src/features/reader/markdown-reader/index.tsx:182-190 — the heading jump the reader already performs for its outline
- PRODUCT.md — "Read … Word … each with the controls its format allows": the format's own navigation is among them
- Let a reader follow a PDF's own links — a 'see Figure 3', citation or table-of-contents click does nothing today #189 — the same landing for PDFs, closed; this is the Word counterpart
- Give Word footnotes the treatment comments got — a note's reference is a link to nowhere today, and its text an unlabeled list at the end #191, Unmerge Word table cells on conversion — today a merged header shifts every value under the wrong heading and drops the cells that overflow #178, Say what a Word header or footer held — the whole part drops without a trace today, though equations and charts get their '(not converted)' markers, so a letter's date or its CONFIDENTIAL status simply vanishes #209 — the other Word structures brought through faithfully; navigation is the one still dropped
Activity
bencode commentedon Oct 29, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Audit at d05b6b6 (2026-10-29): valid — evidence intact (one drifted anchor, corrected below), not implemented on main. No duplicates (#177 is bookmark-less PDF navigation, unrelated).
Evidence checks:
<h2><a id="_Toc123"></a>Results</h2>→## Results(id gone), whileSee <a href="#_Toc123">Section 5</a>→[Section 5](#_Toc123)survives. Exactly as claimed.docx.ts:160-165,167-188— the post-processing passes and Turndown rules (notes, table cells) confirmed; none touch bookmarks.mammoth.browser.js:466-469—bookmarkStart→<a id="…">confirmed.file-link.tsx:18-23,components/markdown.tsx:58-79— a#-href renders as a plain<a href="#…">with no in-document click handling, so the hash finds nothing. Confirmed.index.tsx:182-190— the outline'snavigateToHeading/scrollIntoViewthe proposal reuses. Confirmed.heading-model.ts:38-39is past end-of-file (35 lines); the positional idmarkdown-heading-${index + 1}lives atheading-model.ts:30. Claim itself is correct.Sensor: lint ✓; verify fails as expected (no
bookmarkindocx.ts) — correctly reflects not-implemented.Sharpening suggestions:
bookmarkpresent indocx.ts) is placement-only — a bookmark rule could exist and still lose ids through Turndown. Anchor on the outcome: a conversion test that a fixture withbookmarkStartunder a heading and an internal hyperlink yields a Markdown heading whose id the#-href can target (round-trip, not a grep).#-href naming an in-document id scrolls the pane (thenavigateToHeadingpath), since half the fix is in the reader, notdocx.ts.Staying open; no maintainer signal seen (zero comments, reactions, assignees).
bencode commentedon Oct 31, 2026
Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session. First review ran against
main@d05b6b6; this beat pulled and got the same HEAD, so nothing can have moved — every citation was re-opened fresh.docx.ts:160-165the five post-processing passes (expandMergedCells…unlinkNoteBackLinks),:167-188the Turndown rules (table cell BR, noteReference, note); nothing touches bookmarks, andgrep -c bookmark docx.tsstill returns 0;mammoth.browser.js:466-469(bookmarkStart→<a id=…>withforceWrite); the corrected anchorheading-model.ts:30(markdown-heading-${index + 1}, file is 35 lines) applied to elements atindex.tsx:158-167;file-link.tsx:18-23(a#-href takes the plain-anchor branch) andmarkdown.tsx:58-79(MarkdownAnchorrenders the fragment href with no scroll handling);index.tsx:182-190the outline'snavigateToHeading/scrollIntoViewthe proposal reuses.grep -q bookmarkgate fires; gate is real but placement-only — see below).docx.tswhile half the fix is reader-side (the#-href scroll). An outcome anchor — a conversion round-trip test (bookmark under a heading + internal hyperlink → the#-href targets a surviving id) plus a reader-side scroll test — would make the gate fail until both halves land; without it, a future verify pass can only vouch for thedocx.tshalf.bencode commentedon Nov 6, 2026
Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session. Third pass;
mainis stilld05b6b6(pulled today, "Already up to date"), so nothing can have moved — every anchor was re-opened fresh regardless.docx.ts:160-165(the five post-processing passes) and:167-188(Turndown config +tableCellLineBreak/noteReference/noterules, none touching bookmarks;grep -c bookmarkstill 0);mammoth.browser.js:466-469(bookmarkStart→<a id=…>withforceWrite);heading-model.ts:30(the corrected anchor,markdown-heading-${index + 1}, file 35 lines);index.tsx:158-167(id application) and:182-190(navigateToHeading/scrollIntoView);file-link.tsx:18-23(the#branch takes the plain-anchor path);components/markdown.tsx:58-79(MarkdownAnchorrenders the fragment href with no scroll handling).grep -q "bookmark" docx.tsgate exits 1, exactly the intended not-implemented signal.docx.tspasses it) while half the fix is reader-side. The outcome anchors both prior reviews spelled out — a conversion round-trip test (bookmark under a heading + internal hyperlink → the#-href targets a surviving id) plus a reader-side scroll test throughnavigateToHeading— would keep verify red until both halves land.bencode commentedon Nov 9, 2026
Re-audit (fourth pass) — posted by the scheduled issue-reviewer loop, independent of the authoring session.
mainis stilld05b6b6("Already up to date"), so no citation can have moved; anchors re-opened regardless (docx.ts:160-188post-processing + Turndown rules withgrep -c bookmark= 0;heading-model.ts:30positional ids;mammoth.browser.js:466-469bookmarkStart→<a id>;file-link.tsx:18-23/markdown.tsx:58-79plain-anchor#-href;index.tsx:158-167,182-190). Verdict: valid, keep open (unchanged).Checks new this pass:
formats/docx.tsnor the reader's markdown/link surfaces; no implementation of this proposal is in flight.The standing sharpening — replace the placement grep with an outcome anchor (conversion round-trip test + reader-side
#-href scroll test) — remains the one open suggestion, now unaddressed across four passes.bencode commentedon Nov 11, 2026
Re-audit (fifth pass) — posted by the scheduled issue-reviewer loop, independent of the authoring session.
mainis stilld05b6b6(pulled today, "Already up to date"); anchors re-opened fresh —docx.ts:160-165the five post-processing passes withgrep -c bookmark= 0,mammoth.browser.js:466-469(bookmarkStart→<a id>+forceWrite),heading-model.ts:30positional ids. Verdict: valid, keep open (unchanged).Checks new this pass:
formats/docx.tsor the reader's markdown/link surfaces. No implementation in flight.The standing sharpening — replace the placement grep with an outcome anchor (conversion round-trip test + reader-side
#-href scroll test) — remains open after five passes.