sanitizedanchorname

package
v0.0.0-...-1ce7731 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package sanitizedanchorname provides a func to create sanitized anchor names.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(text string) string

Create returns a sanitized anchor name for the given text.

Example
package main

import (
	"fmt"

	"github.com/shurcooL/gtdo/internal/sanitizedanchorname"
)

func main() {
	anchorName := sanitizedanchorname.Create("This is a header")

	fmt.Println(anchorName)

}
Output:

this-is-a-header
Example (Two)
package main

import (
	"fmt"

	"github.com/shurcooL/gtdo/internal/sanitizedanchorname"
)

func main() {
	fmt.Println(sanitizedanchorname.Create("This is a header"))
	fmt.Println(sanitizedanchorname.Create("This is also          a header"))
	fmt.Println(sanitizedanchorname.Create("main.go"))
	fmt.Println(sanitizedanchorname.Create("Article 123"))
	fmt.Println(sanitizedanchorname.Create("<- Let's try this, shall we?"))
	fmt.Printf("%q\n", sanitizedanchorname.Create("        "))
	fmt.Println(sanitizedanchorname.Create("Hello, 世界"))

}
Output:

this-is-a-header
this-is-also-a-header
main.go
article-123
let-s-try-this-shall-we
""
hello-世界

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL