Skip to content

Commit de755bf

Browse files
committed
Make MUNGE generated table of contents (TOC) bookmark work when there are symbols in the headline
1 parent 8f3c310 commit de755bf

13 files changed

+23
-16
lines changed

cmd/mungedocs/toc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ func buildTOC(markdown []byte) ([]byte, error) {
7575
if numSharps > 0 {
7676
indent := strings.Repeat(" ", numSharps-1)
7777
bookmark := strings.Replace(strings.ToLower(heading), " ", "-", -1)
78+
// remove ' and ? in bookmarks
79+
bookmark = strings.Replace(bookmark, "?", "", -1)
80+
bookmark = strings.Replace(bookmark, "'", "", -1)
7881
tocLine := fmt.Sprintf("%s- [%s](#%s)\n", indent, heading, bookmark)
7982
buffer.WriteString(tocLine)
8083
}

cmd/mungedocs/toc_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func Test_buildTOC(t *testing.T) {
3737
"# Title\nLorem ipsum \n## Section Heading\ndolor sit amet\n```bash\n#!/bin/sh\n```",
3838
"- [Title](#title)\n - [Section Heading](#section-heading)\n",
3939
},
40+
{
41+
"# Title\nLorem ipsum \n## Section Heading\n### Why doesn't this work?\ndolor sit amet\n",
42+
"- [Title](#title)\n - [Section Heading](#section-heading)\n - [Why doesn't this work?](#why-doesnt-this-work)\n",
43+
},
4044
}
4145
for _, c := range cases {
4246
actual, err := buildTOC([]byte(c.in))

docs/admin/admission-controllers.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ certainly want the docs that go with that version.</h1>
2525
**Table of Contents**
2626
<!-- BEGIN MUNGE: GENERATED_TOC -->
2727
- [Admission Controllers](#admission-controllers)
28-
- [What are they?](#what-are-they?)
29-
- [Why do I need them?](#why-do-i-need-them?)
30-
- [How do I turn on an admission control plug-in?](#how-do-i-turn-on-an-admission-control-plug-in?)
31-
- [What does each plug-in do?](#what-does-each-plug-in-do?)
28+
- [What are they?](#what-are-they)
29+
- [Why do I need them?](#why-do-i-need-them)
30+
- [How do I turn on an admission control plug-in?](#how-do-i-turn-on-an-admission-control-plug-in)
31+
- [What does each plug-in do?](#what-does-each-plug-in-do)
3232
- [AlwaysAdmit](#alwaysadmit)
3333
- [AlwaysDeny](#alwaysdeny)
3434
- [DenyExecOnPrivileged](#denyexeconprivileged)
@@ -39,7 +39,7 @@ certainly want the docs that go with that version.</h1>
3939
- [NamespaceExists](#namespaceexists)
4040
- [NamespaceAutoProvision (deprecated)](#namespaceautoprovision-(deprecated))
4141
- [NamespaceLifecycle](#namespacelifecycle)
42-
- [Is there a recommended set of plug-ins to use?](#is-there-a-recommended-set-of-plug-ins-to-use?)
42+
- [Is there a recommended set of plug-ins to use?](#is-there-a-recommended-set-of-plug-ins-to-use)
4343

4444
<!-- END MUNGE: GENERATED_TOC -->
4545

docs/admin/node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ certainly want the docs that go with that version.</h1>
2525
**Table of Contents**
2626
<!-- BEGIN MUNGE: GENERATED_TOC -->
2727
- [Node](#node)
28-
- [What is a node?](#what-is-a-node?)
28+
- [What is a node?](#what-is-a-node)
2929
- [Node Status](#node-status)
3030
- [Node Addresses](#node-addresses)
3131
- [Node Phase](#node-phase)

docs/user-guide/configuring-containers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ certainly want the docs that go with that version.</h1>
3232
- [Viewing pod status](#viewing-pod-status)
3333
- [Viewing pod output](#viewing-pod-output)
3434
- [Deleting pods](#deleting-pods)
35-
- [What's next?](#what's-next?)
35+
- [What's next?](#whats-next)
3636

3737
<!-- END MUNGE: GENERATED_TOC -->
3838

docs/user-guide/connecting-applications.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ certainly want the docs that go with that version.</h1>
3232
- [Environment Variables](#environment-variables)
3333
- [DNS](#dns)
3434
- [Exposing the Service to the internet](#exposing-the-service-to-the-internet)
35-
- [What's next?](#what's-next?)
35+
- [What's next?](#whats-next)
3636

3737
<!-- END MUNGE: GENERATED_TOC -->
3838

docs/user-guide/deploying-applications.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ certainly want the docs that go with that version.</h1>
2929
- [Viewing replication controller status](#viewing-replication-controller-status)
3030
- [Deleting replication controllers](#deleting-replication-controllers)
3131
- [Labels](#labels)
32-
- [What's next?](#what's-next?)
32+
- [What's next?](#whats-next)
3333

3434
<!-- END MUNGE: GENERATED_TOC -->
3535

docs/user-guide/introspection-and-debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ your pods. But there are a number of ways to get even more information about you
3232
- [Using ```kubectl describe pod``` to fetch details about pods](#using-```kubectl-describe-pod```-to-fetch-details-about-pods)
3333
- [Example: debugging Pending Pods](#example:-debugging-pending-pods)
3434
- [Example: debugging a down/unreachable node](#example:-debugging-a-down/unreachable-node)
35-
- [What's next?](#what's-next?)
35+
- [What's next?](#whats-next)
3636

3737
<!-- END MUNGE: GENERATED_TOC -->
3838

docs/user-guide/managing-deployments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You’ve deployed your application and exposed it via a service. Now what? Kuber
3636
- [Updating your application without a service outage](#updating-your-application-without-a-service-outage)
3737
- [In-place updates of resources](#in-place-updates-of-resources)
3838
- [Disruptive updates](#disruptive-updates)
39-
- [What's next?](#what's-next?)
39+
- [What's next?](#whats-next)
4040

4141
<!-- END MUNGE: GENERATED_TOC -->
4242

docs/user-guide/production-pods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ certainly want the docs that go with that version.</h1>
3333
- [Liveness and readiness probes (aka health checks)](#liveness-and-readiness-probes-(aka-health-checks))
3434
- [Lifecycle hooks and termination notice](#lifecycle-hooks-and-termination-notice)
3535
- [Termination message](#termination-message)
36-
- [What's next?](#what's-next?)
36+
- [What's next?](#whats-next)
3737

3838
<!-- END MUNGE: GENERATED_TOC -->
3939

0 commit comments

Comments
 (0)