Skip to content

Add TOC plugin for server-side table of contents generation#776

Open
rolfedh wants to merge 1 commit intoquarkiverse:mainfrom
rolfedh:fix-toc
Open

Add TOC plugin for server-side table of contents generation#776
rolfedh wants to merge 1 commit intoquarkiverse:mainfrom
rolfedh:fix-toc

Conversation

@rolfedh
Copy link

@rolfedh rolfedh commented Mar 9, 2026

Summary

  • Fixes Create a TOC plugin #579
  • Adds a new roq-plugin-toc module that generates a table of contents from page headings in Markdown and AsciiDoc content
  • The plugin is a standalone opt-in dependency (not bundled in the quarkus-roq aggregate extension)

How it works

The plugin parses rendered page HTML with JSoup, extracts headings (h1h6) that have id attributes, and builds a nested hierarchy. It exposes two Qute template extensions on Page:

  • {page.toc} — returns a List<TocEntry> with id, title, level, and children properties for custom rendering
  • {page.tocHtml} — returns a pre-rendered <nav class="roq-toc"> HTML block with nested <ul> lists and anchor links

Both AsciiDoc (div.sect* sections) and Markdown (h*[id] elements) heading formats are supported. All HTML output is XSS-escaped.

This implementation generates static HTML on the server side, consistent with the issue request to "generate the TOC dom in the content." JavaScript-based scroll tracking or active-section highlighting would be a follow-up enhancement.

What's included

  • roq-plugin/toc/ — new plugin module (deployment + runtime)
  • 16 unit tests covering heading extraction (Markdown + AsciiDoc), hierarchy building, HTML rendering, and XSS escaping
  • AsciiDoc documentation page with concept, how-to, and reference sections
  • Navigation and index updates

LLM disclosure

This PR was developed with assistance from Claude Code (Claude Opus 4.6). All code was reviewed, tested, and verified by the author.

Test plan

  • mvn install -DskipTests — full project build succeeds
  • mvn test -pl roq-plugin/toc/runtime — 16 unit tests pass
  • mvn verify — no cross-module regressions (pre-existing RoqCodestartTest failures unrelated)
  • Manually tested with blog/ example: TOC renders correctly for both Markdown and AsciiDoc posts

Fixes quarkiverse#579

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rolfedh rolfedh requested a review from a team as a code owner March 9, 2026 18:56
@ia3andy
Copy link
Collaborator

ia3andy commented Mar 10, 2026

Thanks for the contribution ! I am busy this week, I'll have a careful look next week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a TOC plugin

2 participants