mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #11325 from JanetKuo/toc
Make MUNGE generated TOC bookmark work for symbols
This commit is contained in:
commit
f1c7915d71
@ -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)
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
@ -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 -->
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user