summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-29 09:23:25 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-29 09:23:25 +0100
commit4b2738d87108ac7254b5e18ba842edb838affff4 (patch)
tree3fcc240051335eb890eb0ec838d71943b12b7eae /docs/content/en/functions
parent9c88a8a55adf7779039504fa77d74ec80d658c40 (diff)
parent74309fe5699a595080fdb3a14711e0869babce99 (diff)
Diffstat (limited to 'docs/content/en/functions')
-rw-r--r--docs/content/en/functions/anchorize.md26
-rw-r--r--docs/content/en/functions/humanize.md3
-rw-r--r--docs/content/en/functions/range.md2
3 files changed, 28 insertions, 3 deletions
diff --git a/docs/content/en/functions/anchorize.md b/docs/content/en/functions/anchorize.md
new file mode 100644
index 000000000..a0745edaf
--- /dev/null
+++ b/docs/content/en/functions/anchorize.md
@@ -0,0 +1,26 @@
+---
+title: anchorize
+description: Takes a string and sanitizes it the same way as Blackfriday does for markdown headers.
+date: 2018-10-13
+categories: [functions]
+menu:
+ docs:
+ parent: "functions"
+keywords: [markdown,strings]
+signature: ["anchorize INPUT"]
+hugoversion: "0.39"
+workson: []
+relatedfuncs: [humanize]
+---
+
+The template function uses the [`SanitizedAnchorName` logic from Blackfriday](https://github.com/russross/blackfriday#sanitized-anchor-names).
+Since the same sanitizing logic is used as the markdown parser, you can determine the ID of a header for linking with anchor tags.
+
+```
+{{anchorize "This is a header"}} → "this-is-a-header"
+{{anchorize "This is also a header"}} → "this-is-also-a-header"
+{{anchorize "main.go"}} → "main-go"
+{{anchorize "Article 123"}} → "article-123"
+{{anchorize "<- Let's try this, shall we?"}} → "let-s-try-this-shall-we"
+{{anchorize "Hello, 世界"}} → "hello-世界"
+```
diff --git a/docs/content/en/functions/humanize.md b/docs/content/en/functions/humanize.md
index 2b9a98132..fe06de3a7 100644
--- a/docs/content/en/functions/humanize.md
+++ b/docs/content/en/functions/humanize.md
@@ -14,7 +14,7 @@ keywords: [strings,casing]
signature: ["humanize INPUT"]
workson: []
hugoversion:
-relatedfuncs: []
+relatedfuncs: [anchorize]
deprecated: false
aliases: []
---
@@ -28,4 +28,3 @@ If the input is either an int64 value or the string representation of an integer
{{humanize "52"}} → "52nd"
{{humanize 103}} → "103rd"
```
-
diff --git a/docs/content/en/functions/range.md b/docs/content/en/functions/range.md
index 6f007e93d..f80967c41 100644
--- a/docs/content/en/functions/range.md
+++ b/docs/content/en/functions/range.md
@@ -22,4 +22,4 @@ aliases: []
Just like in the Go programming language, Go and Hugo templates make heavy use of `range` to iterate over a map, array or slice.
-`range` is fundamental to templating in Hugo. (See the [Introduction to Hugo Templates](/templates/introduction/) for more examples.
+`range` is fundamental to templating in Hugo. (See the [Introduction to Hugo Templates](/templates/introduction/) for more examples.)