Skip to content

Commit 566bc25

Browse files
committed
Remove all punctuation from anchors in policies.md
1 parent fdfe524 commit 566bc25

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

examples/policies-no-rego.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* [P2001: Images must not use the latest tag](#p2001-images-must-not-use-the-latest-tag)
2222
* [P2002: Containers must define resource constraints](#p2002-containers-must-define-resource-constraints)
2323
* [P2005: Roles must not allow use of privileged PodSecurityPolicies](#p2005-roles-must-not-allow-use-of-privileged-podsecuritypolicies)
24-
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants'-containers-must-not-run-as-privileged)
24+
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants-containers-must-not-run-as-privileged)
2525

2626
## Warnings
2727

examples/policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* [P2001: Images must not use the latest tag](#p2001-images-must-not-use-the-latest-tag)
2222
* [P2002: Containers must define resource constraints](#p2002-containers-must-define-resource-constraints)
2323
* [P2005: Roles must not allow use of privileged PodSecurityPolicies](#p2005-roles-must-not-allow-use-of-privileged-podsecuritypolicies)
24-
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants'-containers-must-not-run-as-privileged)
24+
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants-containers-must-not-run-as-privileged)
2525

2626
## Warnings
2727

internal/commands/document.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,14 @@ func getDocumentation(path string, outputDirectory string) (map[rego.Severity][]
186186
}
187187

188188
anchor := strings.ToLower(strings.ReplaceAll(documentTitle, " ", "-"))
189-
anchor = strings.ReplaceAll(anchor, ":", "")
189+
// Tab and all ASCII punctuation except - and _
190+
punctReplacer := strings.NewReplacer(
191+
"\t", "", "!", "", "\"", "", "#", "", "$", "", "%", "", "&", "", "'", "", "(", "", ")", "",
192+
"*", "", "+", "", ",", "", ".", "", "/", "", ":", "", ";", "", "<", "", "=", "", ">", "",
193+
"?", "", "@", "", "[", "", "\\", "", "]", "", "^", "", "`", "", "{", "", "|", "", "}", "",
194+
"~", "",
195+
)
196+
anchor = punctReplacer.Replace(anchor)
190197

191198
legacyMatchers, err := policy.Matchers()
192199
if err != nil {

0 commit comments

Comments
 (0)