MCPcopy
hub / github.com/russross/blackfriday / slugify

Function slugify

markdown.go:919–950  ·  view source on GitHub ↗

Create a url-safe slug for fragments

(in []byte)

Source from the content-addressed store, hash-verified

917
918// Create a url-safe slug for fragments
919func slugify(in []byte) []byte {
920 if len(in) == 0 {
921 return in
922 }
923 out := make([]byte, 0, len(in))
924 sym := false
925
926 for _, ch := range in {
927 if isalnum(ch) {
928 sym = false
929 out = append(out, ch)
930 } else if sym {
931 continue
932 } else {
933 out = append(out, '-')
934 sym = true
935 }
936 }
937 var a, b int
938 var ch byte
939 for a, ch = range out {
940 if ch != '-' {
941 break
942 }
943 }
944 for b = len(out) - 1; b > 0; b-- {
945 if out[b] != '-' {
946 break
947 }
948 }
949 return out[a : b+1]
950}

Callers 3

footnoteRefFunction · 0.85
RenderNodeMethod · 0.85
linkFunction · 0.85

Calls 1

isalnumFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…