Implement toc-location option: left/right/body (bd-e2kpwy7n) - #534
Merged
Conversation
…keleton Plan skeleton + Q1 mechanism notes + local repro fixture. Verdict: ready to design — gap confirmed at HEAD, Q1 mechanism mapped, q2 insertion points identified (SCSS and banner template hook already ported and inert). Seven design questions pending user alignment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
All seven design questions answered by the user 2026-08-14; plan promoted from skeleton to implementation plan. Follow-up strands filed: bd-jclcm0in (*-body clone behavior, carries the banner-gate constraint) and bd-tqijrhsu (preview parity for toc-location). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Q1 implements toc-location with a DOM postprocessor moving nav#TOC into a template-emitted placeholder; q2 decides placement up front (no-DOM-postprocessor rule): - New TocLocationTransform (Navigation phase, between TocRender and SidebarRender) normalizes toc-location and publishes rendered.navigation.toc-location plus placement flags (toc-relocated / toc-left / toc-body / toc-in-sidebar); also fires the previously-inert banner-header-class toc-left hook. - Website regime (ProjectKind::Website): SidebarRenderTransform appends the TOC block inside nav#quarto-sidebar after the nav items (new sidebar_to_html_with_appended seam in quarto-navigation), or synthesizes a TOC-only floating sidebar when none is configured. - Standalone regime: the template emits div#quarto-sidebar-toc-left.sidebar.toc-left and puts the toc-left grid class on #quarto-content (SCSS was already ported and inert). - body: the TOC renders in <main> between title block and body, keeping q2's decorated markup (deliberate Q1 deviation, decision 4). - New toc-block template partial shared by the three template-emitted placements; Rust twin toc_block_html for the sidebar merge. - left-body/right-body warn (new Q-13-8 + docs page) and fall back to left/right until bd-jclcm0in; unknown values warn and default right. - Deliberate deviation (decision 5): no empty #quarto-margin-sidebar shell when the TOC leaves the margin. - Docs: filled the navigation.qmd stub with TOC + toc-location usage. Tests: 11 new e2e integration tests (toc_location.rs) written first and verified failing; 1 new template unit test for the margin-categories interaction. Zero snapshot changes — the right/default path is byte-stable. Full workspace suite green (12,111 passed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
…-location # Conflicts: # crates/quarto-error-catalog/error_catalog.json
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.
Summary
Implements the
toc-locationoption for HTML output (left,right,body), closing the gap tracked as bd-e2kpwy7n. This also un-inerts the bannertoc-leftheader-class hook and the already-ported.page-columns.toc-left/.sidebar.toc-leftSCSS.Q1 implements this with a DOM postprocessor that moves
nav#TOCinto a template-emitted placeholder; q2 has no DOM-postprocessor stage, so placement is decided up front:TocLocationTransform(Navigation phase, between TocRender and SidebarRender) normalizes the option, publishesrendered.navigation.toc-location+ placement flags (toc-relocated/toc-left/toc-body/toc-in-sidebar), and producesquarto-template-params.banner-header-class: toc-leftwhen a banner is active.ProjectKind::Website, mirroring Q1'ssidebar.ejs):SidebarRenderTransformappends the TOC block insidenav#quarto-sidebarafter the nav items via a newsidebar_to_html_with_appendedseam in quarto-navigation, or synthesizes a TOC-only floating sidebar (body classesnav-sidebar floating) when no sidebar is configured.sidebar: falsestill synthesizes, matching Q1'snav.sidebar || navbarTocLeftgate.before-body-article.ejs): the template emitsdiv#quarto-sidebar-toc-left.sidebar.toc-leftand adds thetoc-leftgrid class to#quarto-content.body: the TOC renders inside<main>between the title block and the body.toc-blocktemplate partial is shared by the three template-emitted placements (Rust twintoc_block_htmlfor the sidebar merge).left-body/right-bodywarn (new Q-13-8 diagnostic + error docs page) and fall back toleft/right(double-TOC clone tracked as bd-jclcm0in); unknown values warn and default toright.Deliberate deviations from Q1 (design decisions recorded in
claude-notes/plans/2026-08-14-toc-location.md):#quarto-margin-sidebarshell when the TOC leaves the margin (Q1 keeps an emptyzindex-bottomelement).bodyTOC keeps q2's decorated markup (nav-link,data-scroll-target) instead of Q1's plain list, anticipating scroll-spy support.Docs: fills the
guides/authoring/navigation.qmdstub with TOC +toc-locationusage.Follow-ups filed: bd-jclcm0in (
*-bodyclones, carries the banner-gate constraint), bd-tqijrhsu (preview parity —q2 preview's TocSlot still renders the margin TOC), bd-eczdzfqo (pre-existingrole=\"doc-toc\"on the sidebar nav now nests roles).Test plan
crates/quarto-core/tests/integration/toc_location.rs) written first and verified failing — both regimes ofleft,body, explicit-right-equals-default, banner composition,*-body/unknown fallback warnings.right/default path is byte-stable.cargo xtask verifypassed including hub-client/WASM legs.nav#TOCinsidenav#quarto-sidebar…sidebar-floatingwithbody.floatingand no margin sidebar; a standalone doc gets#quarto-content.toc-left+#quarto-sidebar-toc-left. Real-world validation against the Connect-docsapi/index.html(201-entry TOC) planned for a follow-up session.🤖 Generated with Claude Code