forked from GoPerry/upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
html_parser.sed
95 lines (95 loc) · 956 Bytes
/
html_parser.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#n
/^<!--/{
:nc
/-->/!{
N
s/\n/@HTML_CR/1
b nc
}
s/-->\(.\)/-->@HTML_SEP\n\1/1
P
D
}
/^<?/{
:nqm
/?>/!{
N
s/\n/@HTML_CR/1
b nqm
}
s/?>\(.\)/?>@HTML_SEP\n\1/1
P
D
}
/^<!/{
:nss
/>/!{
N
s/\n/@HTML_CR/1
b nss
}
s/>\(.\)/>@HTML_SEP\n\1/1
P
D
}
/^</{
:nes
/^[^'"]*>/{
s/>\(.\)/>@HTML_SEP\n\1/1
P
D
}
/^[^"']*=[ \t]*"/!b iflqs
s/"/@HTML_QD/1
:nrqd
/"/!{
N
s/\n/@HTML_CR/1
b nrqd
}
s/"/@HTML_RQD/1
:rqs
/'.*@HTML_RQD/{
s/'\(.*@HTML_RQD\)/@HTML_QS\1/1
b rqs
}
:rrab
/>.*@HTML_RQD/{
s/>\(.*@HTML_RQD\)/@HTML_RAB\1/1
b rrab
}
s/@HTML_RQD/@HTML_QD/1
b nes
:iflqs
/^[^"']*=[ \t]*'/!{
N
s/\n/@HTML_CR/1
b nes
}
s/'/@HTML_QS/1
:nrqs
/'/!{
N
s/\n/@HTML_CR/1
b nrqs
}
s/'/@HTML_RQS/1
:rqd
/".*@HTML_RQS/{
s/"\(.*@HTML_RQS\)/@HTML_QD\1/1
b rqd
}
:rrab
/>.*@HTML_RQS/{
s/>\(.*@HTML_RQS\)/@HTML_RAB\1/1
b rrab
}
s/@HTML_RQS/@HTML_QS/1
b nes
}
/</{
s//@HTML_SEP\n</1
P
D
}
p