]> git.plutz.net Git - cgilite/blob - html-sh.sed
enable connection reuse in builtin web server
[cgilite] / html-sh.sed
1 #!/bin/sed -nrf
2
3 :CommentHandle
4 x; /^<\/!-->/{
5   x; /--]/{
6     H; s;^(.*)--].*$;\1-->;p;
7     g; s;^.*--]([^\n]*)$;\1;
8     x; s;^</!-->\n(.*)\n[^\n]*$;\1;; x;
9     bCommentEnd
10   }
11   p; b;
12 }
13 x;
14 :CommentEnd
15
16 :shortcuts
17 s;\[hidden[ \t]+"([^"]*)"[ \t]+"([^"]*)";[input type="hidden" name="\1" value="\2";g;
18 s;\[checkbox[ \t]+"([^"]*)"[ \t]+"([^"]*)";[input type="checkbox" name="\1" value="\2";g;
19 s;\[radio[ \t]+"([^"]*)"[ \t]+"([^"]*)";[input type="radio" name="\1" value="\2";g;
20 s;\[submit[ \t]+"([^"]*)"[ \t]+"([^"]*)";[button type="submit" name="\1" value="\2";g;
21 s;\[a[ \t]+"([^"]*)";[a href="\1";g;
22 s;\[img[ \t]+"([^"]*)"[ \t]+"([^"]*)";[img src="\1" alt="\2";g;
23
24 s;\[!([^]\[]*)\];<!\1>;g;
25 s;\[!--([^]\[]*)--\];<!--\1-->;g;
26
27 :tags
28 s;\[([^]\[< \t]+)([^]\[]*)\];<\1>\2</\1>;g;
29 t tags;
30
31 G;
32 :tagclose
33 s;^([^]\n]*)\]([^\n]*)\n([^\n]+);\1\3\2;
34 t tagclose;
35 h; s;^([^\n]*)\n;;; x; s;\n.*$;;;
36
37 :tagopen
38 s;^([^\[\n]*)\[([^]\[< \t\n]+)([^\n]*);\1<\2>\3\n</\2>;
39 t tagopen;
40 G; h; s;^[^\n]*\n+;;; x; s;\n.*$;;;
41
42 :attribs
43 s;class="([^>]+)>[ \t]+\.([^< \t]+);class="\2 \1>;g; t attribs;
44 s;>[ \t]+\.([^< \t]+); class="\1">;g;
45 s;>[ \t]+#([^< \t]+); id="\1">;g;
46 s;>[ \t]+([^ \t=<]+=("[^"]*"|'[^']*'|[^< \t]*)); \1>;g;
47 s;(<input type="(checkbox|radio)" [^>]+)>[ \t]+checked;\1 checked="checked">;g;
48 t attribs;
49
50 s;(<[^/][^>]*>)[ \t]*;\1;g;
51 s;(<[^/][^>]*)>[ \t]*</[^>]+>;\1/>;g;
52
53 s;<!-->;<!--;;
54
55 p; ${g; s;\n+;;g; p;}