]> git.plutz.net Git - confetti/blob - cgilite/html-sh.sed
bugfix: do not guess known IBANs
[confetti] / cgilite / html-sh.sed
1 #!/bin/sed -nEf
2
3 # Copyright 2018 - 2019 Paul Hänsch
4
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8
9 # THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15 # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17 :Escapes
18 s,\\\\,\\,g; s,\\&,\&,g;
19 s,\\<,\&lt;,g; s,\\>,\&gt;,g;
20 s,\\",\&quot;,g; s,\\',\&apos;,g;
21 s,\\\[,\&#91;,g; s,\\\],\&#93;,g;
22 s,\\\.,\&#46;,g; s,\\#,\&#35;,g;
23 s,\\,,g;
24
25 :CommentHandle
26 x; /^<\/!-->/{
27   x; /--]/{
28     H; s;^(.*)--].*$;\1-->;p;
29     g; s;^.*--]([^\n]*)$;\1;
30     x; s;^</!-->\n(.*)\n[^\n]*$;\1;; x;
31     bCommentEnd
32   }
33   p; b;
34 }
35 x;
36 :CommentEnd
37
38 :shortcuts
39 s;\[hidden[ \t]+"([^"]*)"[ \t]+"([^"]*)";[input type="hidden" name="\1" value="\2";g;
40 s;\[checkbox[ \t]+"([^"]*)"[ \t]+"([^"]*)";[input type="checkbox" name="\1" value="\2";g;
41 s;\[radio[ \t]+"([^"]*)"[ \t]+"([^"]*)";[input type="radio" name="\1" value="\2";g;
42 s;\[submit[ \t]+"([^"]*)"[ \t]+"([^"]*)";[button type="submit" name="\1" value="\2";g;
43 s;\[a[ \t]+"([^"]*)";[a href="\1";g;
44 s;\[img[ \t]+"([^"]*)"[ \t]+"([^"]*)";[img src="\1" alt="\2";g;
45
46 s;\[!([^]\[]*)\];<!\1>;g;
47 s;\[!--([^]\[]*)--\];<!--\1-->;g;
48
49 :tags
50 s;\[([^]\[< \t]+)([^]\[]*)\];<\1>\2</\1>;g;
51 t tags;
52
53 G;
54 :tagclose
55 s;^([^]\n]*)\]([^\n]*)\n([^\n]+);\1\3\2;
56 t tagclose;
57 h; s;^([^\n]*)\n;;; x; s;\n.*$;;;
58
59 :tagopen
60 s;^([^\[\n]*)\[([^]\[< \t\n]+)([^\n]*);\1<\2>\3\n</\2>;
61 t tagopen;
62 G; h; s;^[^\n]*\n+;;; x; s;\n.*$;;;
63
64 :attribs
65 s;class="([^>]+)>[ \t]*\.([^< \t]+);class="\2 \1>;g; t attribs;
66 s;(<[^/][^>]*)>[ \t]*\.([^< \t]+);\1 class="\2">;g;
67 s;(<[^/][^>]*)>[ \t]*#([^< \t]+);\1 id="\2">;g;
68 s;(<[^/][^>]*)>[ \t]*([^ \t=<]+=("[^"]*"|'[^']*'|[^< \t]*));\1 \2>;g;
69 t attribs;
70 s;(<input ([^>]+ )?type=(radio|"radio"|'radio')( [^>]+)?)>[ \t]*(checked|selected);\1 checked="checked">;g;
71 s;(<input ([^>]+ )?type=(checkbox|"checkbox"|'checkbox')( [^>]+)?)>[ \t]*(checked|selected);\1 checked="checked">;g;
72 s;(<option( [^>]+)?)>[ \t]*(checked|selected);\1 selected="selected">;g;
73 s;(<select( [^>]+)?)>[ \t]*multiple;\1 multiple="multiple">;g;
74 t attribs;
75 s;(<[^/][^>]*>)[ \t]*\.[ \t];\1;g;
76
77 s;(<[^/][^>]*>)[ \t]*;\1;g;
78 # s;(<[^/][^>]*)>[ \t]*</[^>]+>;\1/>;g;
79 s;(<(br|hr|img|input|link|meta|area|base|col|command|embed|keygen|param|source|track|wbr)[^>]*)>[ \t]*</\1>;\1>;g;
80
81 s;<!-->;<!--;;
82
83 p; ${g; s;\n+;;g; p;}