codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

feat(repo): add a GitHub-style outline popup to rendered Markdown #221

Merged
pat-s merged 1 commit from feat/markdown-outline into v16.0/forgejo-codefloe 2026-10-04 13:46:14 +00:00
Owner

Rendered Markdown files and READMEs get an Outline button in the file header, like GitHub's.
It opens a popup listing the document's headings, nested by level, with a filter box; clicking a heading jumps to it.

Upstream only shows a table of contents in the wiki, although the Markdown renderer builds the heading list for every document and the file view discards it.

What it adds

  • routers/web/repo/view.go: one call in markupRender, so file views, READMEs on the repository home and other rendered markup files all get the outline.
  • routers/web/repo/view_codefloe.go: render RenderContext.SidebarTocNode as FileOutline, the same node the wiki sidebar uses, so nothing is parsed twice; move each sub-list into its parent item first, because modules/markup/markdown/toc.go emits <ul> directly inside <ul> (axe's list rule flags it).
  • templates/repo/codefloe_file_outline.tmpl, included in the header of templates/repo/view_file.tmpl: the button, in the same ui compact icon buttons group markup as the source/rendered toggle so it matches its size.
  • templates/repo/codefloe_file_outline_popup.tmpl, included at the end of the file view: the hidden popup, kept out of h4.file-header because upstream's TestViewRepoDirectoryReadme expects the header text to be the file name.
  • web_src/js/codefloe/file-outline.js: a delegated, lazily created tippy popup with an accessible name; the filter keeps the parents of a matching subheading visible and shows "No matching headings" when nothing matches; clicking a heading closes the popup.
  • web_src/css/codefloe/file-outline.css: compact nested list with theme variables, checked in codefloe-* and codefloe-tide-* light and dark.
  • options/locale_next/locale_en-US.json: three strings.
  • README.md: custom changes row.

Behaviour

  • On by default, no setting.
  • The button only shows in rendered mode (not ?display=source) and only when the document has headings.
  • Front matter is respected: include_toc: false hides the button, include_toc: main keeps the inline table of contents and shows no button.

Tests

  • tests/integration/codefloe_file_outline_test.go: link targets and texts, HTML escaping of heading text, valid nesting including a skipped heading level, the README on the repository home, and no button for source view, include_toc: false/main, a file without headings and a non-Markdown file.
  • web_src/js/codefloe/file-outline.test.js: filter behaviour, 6 tests.
  • tests/e2e/codefloe-file-outline.test.e2e.ts: open, focus, axe scan, filter, empty state, jump to a heading and popup close, in chromium, firefox and Mobile Chrome.
  • Related upstream e2e specs pass locally (layout-shift, clipboard-copy, codefloe-tide-theme, markup, repo-wiki).
    repo-code › Readable diff (firefox only) fails intermittently with ChunkLoadError: Loading chunk repo-switcher failed; an untouched base build fails it the same way.
Rendered Markdown files and READMEs get an Outline button in the file header, like GitHub's. It opens a popup listing the document's headings, nested by level, with a filter box; clicking a heading jumps to it. Upstream only shows a table of contents in the wiki, although the Markdown renderer builds the heading list for every document and the file view discards it. ## What it adds - `routers/web/repo/view.go`: one call in `markupRender`, so file views, READMEs on the repository home and other rendered markup files all get the outline. - `routers/web/repo/view_codefloe.go`: render `RenderContext.SidebarTocNode` as `FileOutline`, the same node the wiki sidebar uses, so nothing is parsed twice; move each sub-list into its parent item first, because `modules/markup/markdown/toc.go` emits `<ul>` directly inside `<ul>` (axe's `list` rule flags it). - `templates/repo/codefloe_file_outline.tmpl`, included in the header of `templates/repo/view_file.tmpl`: the button, in the same `ui compact icon buttons` group markup as the source/rendered toggle so it matches its size. - `templates/repo/codefloe_file_outline_popup.tmpl`, included at the end of the file view: the hidden popup, kept out of `h4.file-header` because upstream's `TestViewRepoDirectoryReadme` expects the header text to be the file name. - `web_src/js/codefloe/file-outline.js`: a delegated, lazily created tippy popup with an accessible name; the filter keeps the parents of a matching subheading visible and shows "No matching headings" when nothing matches; clicking a heading closes the popup. - `web_src/css/codefloe/file-outline.css`: compact nested list with theme variables, checked in `codefloe-*` and `codefloe-tide-*` light and dark. - `options/locale_next/locale_en-US.json`: three strings. - `README.md`: custom changes row. ## Behaviour - On by default, no setting. - The button only shows in rendered mode (not `?display=source`) and only when the document has headings. - Front matter is respected: `include_toc: false` hides the button, `include_toc: main` keeps the inline table of contents and shows no button. ## Tests - `tests/integration/codefloe_file_outline_test.go`: link targets and texts, HTML escaping of heading text, valid nesting including a skipped heading level, the README on the repository home, and no button for source view, `include_toc: false`/`main`, a file without headings and a non-Markdown file. - `web_src/js/codefloe/file-outline.test.js`: filter behaviour, 6 tests. - `tests/e2e/codefloe-file-outline.test.e2e.ts`: open, focus, axe scan, filter, empty state, jump to a heading and popup close, in chromium, firefox and Mobile Chrome. - Related upstream e2e specs pass locally (`layout-shift`, `clipboard-copy`, `codefloe-tide-theme`, `markup`, `repo-wiki`). `repo-code` › `Readable diff` (firefox only) fails intermittently with `ChunkLoadError: Loading chunk repo-switcher failed`; an untouched base build fails it the same way.
pat-s force-pushed feat/markdown-outline from a0d54ec2ee
Some checks failed
testing / frontend-checks (pull_request) Successful in 2m37s
testing / test-unit (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
testing / backend-checks (pull_request) Successful in 6m59s
testing / test-e2e (1/2) (pull_request) Successful in 3m11s
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-e2e (2/2) (pull_request) Successful in 2m54s
to 9b2f077fae
Some checks failed
testing / frontend-checks (pull_request) Successful in 1m27s
testing / test-e2e (2/2) (pull_request) Successful in 2m56s
testing / backend-checks (pull_request) Successful in 5m18s
testing / test-e2e (1/2) (pull_request) Successful in 3m43s
testing / test-pgsql (1/4) (pull_request) Successful in 9m18s
testing / test-unit (pull_request) Successful in 8m32s
testing / test-pgsql (3/4) (pull_request) Successful in 10m21s
testing / test-pgsql (4/4) (pull_request) Successful in 11m0s
testing / test-pgsql (2/4) (pull_request) Failing after 4m35s
2026-10-04 12:57:45 +00:00
Compare
pat-s scheduled this pull request to auto merge when all checks succeed 2026-10-04 13:08:25 +00:00
pat-s force-pushed feat/markdown-outline from 9b2f077fae
Some checks failed
testing / frontend-checks (pull_request) Successful in 1m27s
testing / test-e2e (2/2) (pull_request) Successful in 2m56s
testing / backend-checks (pull_request) Successful in 5m18s
testing / test-e2e (1/2) (pull_request) Successful in 3m43s
testing / test-pgsql (1/4) (pull_request) Successful in 9m18s
testing / test-unit (pull_request) Successful in 8m32s
testing / test-pgsql (3/4) (pull_request) Successful in 10m21s
testing / test-pgsql (4/4) (pull_request) Successful in 11m0s
testing / test-pgsql (2/4) (pull_request) Failing after 4m35s
to f977140014
All checks were successful
testing / test-e2e (1/2) (pull_request) Successful in 5m16s
testing / test-pgsql (2/4) (pull_request) Successful in 6m6s
testing / test-pgsql (4/4) (pull_request) Successful in 12m5s
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Has been skipped
testing / frontend-checks (pull_request) Successful in 1m24s
testing / test-unit (pull_request) Successful in 9m58s
testing / backend-checks (pull_request) Successful in 5m36s
testing / test-e2e (2/2) (pull_request) Successful in 4m8s
testing / test-pgsql (1/4) (pull_request) Successful in 10m50s
testing / test-pgsql (3/4) (pull_request) Successful in 11m58s
2026-10-04 13:28:26 +00:00
Compare
pat-s merged commit b0fd5bccf1 into v16.0/forgejo-codefloe 2026-10-04 13:46:14 +00:00
pat-s deleted branch feat/markdown-outline 2026-10-04 13:46:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!221
No description provided.