MCPcopy
hub / github.com/docsifyjs/docsify / slugify

Function slugify

src/core/render/slugify.js:10–33  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

8}
9
10export function slugify(str) {
11 if (typeof str !== 'string') {
12 return '';
13 }
14
15 let slug = str
16 .trim()
17 .replace(/[A-Z]+/g, lower)
18 .replace(/<[^>]+>/g, '')
19 .replace(re, '')
20 .replace(/\s/g, '-')
21 .replace(/-+/g, '-')
22 .replace(/^(\d)/, '_$1');
23 let count = cache[slug];
24
25 count = hasOwn.call(cache, slug) ? count + 1 : 0;
26 cache[slug] = count;
27
28 if (count) {
29 slug = slug + '-' + count;
30 }
31
32 return slug;
33}
34
35slugify.clear = function () {
36 cache = {};

Callers 4

_initRendererMethod · 0.90
headingCompilerFunction · 0.90
genIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…