Skip to content

Commit

Permalink
Make MUNGE generated table of contents (TOC) bookmark work when there…
Browse files Browse the repository at this point in the history
… are symbols in the headline
  • Loading branch information
janetkuo committed Jul 15, 2015
1 parent 8f3c310 commit de755bf
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 16 deletions.
3 changes: 3 additions & 0 deletions cmd/mungedocs/toc.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func buildTOC(markdown []byte) ([]byte, error) {
if numSharps > 0 {
indent := strings.Repeat(" ", numSharps-1)
bookmark := strings.Replace(strings.ToLower(heading), " ", "-", -1)
// remove ' and ? in bookmarks
bookmark = strings.Replace(bookmark, "?", "", -1)
bookmark = strings.Replace(bookmark, "'", "", -1)
tocLine := fmt.Sprintf("%s- [%s](#%s)\n", indent, heading, bookmark)
buffer.WriteString(tocLine)
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/mungedocs/toc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func Test_buildTOC(t *testing.T) {
"# Title\nLorem ipsum \n## Section Heading\ndolor sit amet\n```bash\n#!/bin/sh\n```",
"- [Title](#title)\n - [Section Heading](#section-heading)\n",
},
{
"# Title\nLorem ipsum \n## Section Heading\n### Why doesn't this work?\ndolor sit amet\n",
"- [Title](#title)\n - [Section Heading](#section-heading)\n - [Why doesn't this work?](#why-doesnt-this-work)\n",
},
}
for _, c := range cases {
actual, err := buildTOC([]byte(c.in))
Expand Down
10 changes: 5 additions & 5 deletions docs/admin/admission-controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ certainly want the docs that go with that version.</h1>
**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->
- [Admission Controllers](#admission-controllers)
- [What are they?](#what-are-they?)
- [Why do I need them?](#why-do-i-need-them?)
- [How do I turn on an admission control plug-in?](#how-do-i-turn-on-an-admission-control-plug-in?)
- [What does each plug-in do?](#what-does-each-plug-in-do?)
- [What are they?](#what-are-they)
- [Why do I need them?](#why-do-i-need-them)
- [How do I turn on an admission control plug-in?](#how-do-i-turn-on-an-admission-control-plug-in)
- [What does each plug-in do?](#what-does-each-plug-in-do)
- [AlwaysAdmit](#alwaysadmit)
- [AlwaysDeny](#alwaysdeny)
- [DenyExecOnPrivileged](#denyexeconprivileged)
Expand All @@ -39,7 +39,7 @@ certainly want the docs that go with that version.</h1>
- [NamespaceExists](#namespaceexists)
- [NamespaceAutoProvision (deprecated)](#namespaceautoprovision-(deprecated))
- [NamespaceLifecycle](#namespacelifecycle)
- [Is there a recommended set of plug-ins to use?](#is-there-a-recommended-set-of-plug-ins-to-use?)
- [Is there a recommended set of plug-ins to use?](#is-there-a-recommended-set-of-plug-ins-to-use)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
2 changes: 1 addition & 1 deletion docs/admin/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ certainly want the docs that go with that version.</h1>
**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->
- [Node](#node)
- [What is a node?](#what-is-a-node?)
- [What is a node?](#what-is-a-node)
- [Node Status](#node-status)
- [Node Addresses](#node-addresses)
- [Node Phase](#node-phase)
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/configuring-containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ certainly want the docs that go with that version.</h1>
- [Viewing pod status](#viewing-pod-status)
- [Viewing pod output](#viewing-pod-output)
- [Deleting pods](#deleting-pods)
- [What's next?](#what's-next?)
- [What's next?](#whats-next)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/connecting-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ certainly want the docs that go with that version.</h1>
- [Environment Variables](#environment-variables)
- [DNS](#dns)
- [Exposing the Service to the internet](#exposing-the-service-to-the-internet)
- [What's next?](#what's-next?)
- [What's next?](#whats-next)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/deploying-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ certainly want the docs that go with that version.</h1>
- [Viewing replication controller status](#viewing-replication-controller-status)
- [Deleting replication controllers](#deleting-replication-controllers)
- [Labels](#labels)
- [What's next?](#what's-next?)
- [What's next?](#whats-next)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/introspection-and-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ your pods. But there are a number of ways to get even more information about you
- [Using ```kubectl describe pod``` to fetch details about pods](#using-```kubectl-describe-pod```-to-fetch-details-about-pods)
- [Example: debugging Pending Pods](#example:-debugging-pending-pods)
- [Example: debugging a down/unreachable node](#example:-debugging-a-down/unreachable-node)
- [What's next?](#what's-next?)
- [What's next?](#whats-next)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/managing-deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You’ve deployed your application and exposed it via a service. Now what? Kuber
- [Updating your application without a service outage](#updating-your-application-without-a-service-outage)
- [In-place updates of resources](#in-place-updates-of-resources)
- [Disruptive updates](#disruptive-updates)
- [What's next?](#what's-next?)
- [What's next?](#whats-next)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/production-pods.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ certainly want the docs that go with that version.</h1>
- [Liveness and readiness probes (aka health checks)](#liveness-and-readiness-probes-(aka-health-checks))
- [Lifecycle hooks and termination notice](#lifecycle-hooks-and-termination-notice)
- [Termination message](#termination-message)
- [What's next?](#what's-next?)
- [What's next?](#whats-next)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ certainly want the docs that go with that version.</h1>
- [Launching a simple application](#launching-a-simple-application)
- [Exposing your application to the Internet](#exposing-your-application-to-the-internet)
- [Killing the application](#killing-the-application)
- [What's next?](#what's-next?)
- [What's next?](#whats-next)

<!-- END MUNGE: GENERATED_TOC -->

Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/replication-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ certainly want the docs that go with that version.</h1>
**Table of Contents**
<!-- BEGIN MUNGE: GENERATED_TOC -->
- [Replication Controller](#replication-controller)
- [What is a _replication controller_?](#what-is-a-_replication-controller_?)
- [How does a replication controller work?](#how-does-a-replication-controller-work?)
- [What is a _replication controller_?](#what-is-a-_replication-controller_)
- [How does a replication controller work?](#how-does-a-replication-controller-work)
- [Pod template](#pod-template)
- [Labels](#labels)
- [Responsibilities of the replication controller](#responsibilities-of-the-replication-controller)
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ certainly want the docs that go with that version.</h1>
- [Virtual IPs and service proxies](#virtual-ips-and-service-proxies)
- [Multi-Port Services](#multi-port-services)
- [Choosing your own IP address](#choosing-your-own-ip-address)
- [Why not use round-robin DNS?](#why-not-use-round-robin-dns?)
- [Why not use round-robin DNS?](#why-not-use-round-robin-dns)
- [Discovering services](#discovering-services)
- [Environment variables](#environment-variables)
- [DNS](#dns)
Expand Down

0 comments on commit de755bf

Please sign in to comment.