Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
656ce4b6
Commit
656ce4b6
authored
Jul 06, 2016
by
Tim St. Clair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mungedocs TOC generation
Fix TOC links in the presence duplicate headers.
parent
61e4ba94
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
toc.go
cmd/mungedocs/toc.go
+7
-0
No files found.
cmd/mungedocs/toc.go
View file @
656ce4b6
...
...
@@ -51,6 +51,7 @@ func updateTOC(filePath string, mlines mungeLines) (mungeLines, error) {
func
buildTOC
(
mlines
mungeLines
)
mungeLines
{
var
out
mungeLines
bookmarks
:=
map
[
string
]
int
{}
for
_
,
mline
:=
range
mlines
{
if
mline
.
preformatted
||
!
mline
.
header
{
...
...
@@ -69,6 +70,12 @@ func buildTOC(mlines mungeLines) mungeLines {
bookmark
:=
strings
.
Replace
(
strings
.
ToLower
(
heading
),
" "
,
"-"
,
-
1
)
// remove symbols (except for -) in bookmarks
bookmark
=
r
.
ReplaceAllString
(
bookmark
,
""
)
// Incremental counter for duplicate bookmarks
next
:=
bookmarks
[
bookmark
]
bookmarks
[
bookmark
]
=
next
+
1
if
next
>
0
{
bookmark
=
fmt
.
Sprintf
(
"%s-%d"
,
bookmark
,
next
)
}
tocLine
:=
fmt
.
Sprintf
(
"%s- [%s](#%s)"
,
indent
,
heading
,
bookmark
)
out
=
append
(
out
,
newMungeLine
(
tocLine
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment