-
Notifications
You must be signed in to change notification settings - Fork 16
/
simov_slugify.javascript.txt
34 lines (29 loc) · 3.12 KB
/
simov_slugify.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
SIMOV_SLUGIFY
ALTERNATIVES ==> # - simov slugify (almost preferred)
# - more allowed characters
# - sindresorhus slugify (preferred):
# - handles camelCase better
# - can append indices to duplicate return values
VERSION ==> #1.6.6
SLUGIFY(STR[, OPTS|STR2])->STR #Transform a string to dasherized lowecase with only [0-9a-zA-Z$*_+~.()'"!:@-]
#Does:
# - STR.normalize()
# - dasherize lowercase: AbcDef -> abcdef, Abc Def -> abc-def
# - only lowercase if OPTS.lower true (def: false)
# - remove anything that is not [\s0-9a-zA-Z$*_+~.()'"!:@-]
# - i.e. any character allowed unescaped in PATH:
# - except & , ; = / ?
# - and with also "
# - if OPTS.remove /REGEXP/g, use that instead
# - if OPTS.strict true (def: false), anything not [0-9a-zA-Z] instead
# - replace|squash spaces by OPTS.replacement STR2 (def: '-')
# - trim whitespaces if OPTS.trim true (def)
# - try to normalize Unicode -> ASCII:
# - by removing accents or using a similar character
# - including alternative quotes symbols
# - replace $ & < > | % by "dollar|and|less|greater|or|percent"
# - replace some Unicode chars by their names (e.g. currencies)
# - replace some language-specific characters according to OPT.locale 'LANG'
# - for each key after SLUGIFY.extend({ STR: STR2, ... }), replace STR by STR2