diff options
author | zeripath <art27@cantab.net> | 2022-06-08 09:59:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-08 16:59:16 +0800 |
commit | ac88f21ecc5612befe51f7ab6ffcb76c681daba5 (patch) | |
tree | cbe281221d0703da0f1ecce428888e036ef311d7 /modules/markup/renderer.go | |
parent | c1c07e533c9ca3be13b4af057b6b989402c12f6e (diff) | |
download | gitea-ac88f21ecc5612befe51f7ab6ffcb76c681daba5.tar.gz gitea-ac88f21ecc5612befe51f7ab6ffcb76c681daba5.zip |
Automatically render wiki TOC (#19873)
Automatically add sidebar in the wiki view containing a TOC for the wiki page.
Make the TOC collapsable
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/markup/renderer.go')
-rw-r--r-- | modules/markup/renderer.go | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/modules/markup/renderer.go b/modules/markup/renderer.go index cf8b9bace7..53ecbfce2b 100644 --- a/modules/markup/renderer.go +++ b/modules/markup/renderer.go @@ -33,18 +33,26 @@ func Init() { } } +// Header holds the data about a header. +type Header struct { + Level int + Text string + ID string +} + // RenderContext represents a render context type RenderContext struct { - Ctx context.Context - Filename string - Type string - IsWiki bool - URLPrefix string - Metas map[string]string - DefaultLink string - GitRepo *git.Repository - ShaExistCache map[string]bool - cancelFn func() + Ctx context.Context + Filename string + Type string + IsWiki bool + URLPrefix string + Metas map[string]string + DefaultLink string + GitRepo *git.Repository + ShaExistCache map[string]bool + cancelFn func() + TableOfContents []Header } // Cancel runs any cleanup functions that have been registered for this Ctx |