-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrefs.sed
63 lines (46 loc) · 969 Bytes
/
refs.sed
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# __AUTHOR(⟦Josef Kubin⟧, ⟦2020,03,30⟧)
# ___DESCR(⟦converts strings for anchors/files to a plain-text-string format⟧)
# __REASON(⟦generate references at the lightning speed⟧)
# process strings for file names
/^file/{
s///
x
N
# convert uppercase letters to lovercase
s/.*/\L&/
# transliterate lovercase UTF-8 to ASCII
y/áčďéěíňóřšťúůýž/acdeeinorstuuyz/
# change problematic characters to -
s/[–[:space:][:punct:]]/-/g
# shrink duplicit -
s/--\+/-/g
# remove prefix -
s/^-//
bfinish
}
# process strings for anchor names
/^anch/{
s///
x
N
# convert uppercase letters to lovercase
s/.*/\L&/
# transliterate lowercase UTF-8 to ASCII
y/áčďéěíňóřšťúůýž/acdeeinorstuuyz/
# change problematic characters to -
s/[–[:space:][:punct:]]/-/g
# shrink duplicit -
s/--\+/-/g
# remove prefix -
s/^-//
# truncate too long string
s/^\(.\{,32\}\).*$/\1/
:finish
# remove (possible) trailing -
s/-$//
N
H
z
x
s/\n//g
}