3 # Copyright 2018 - 2019 Paul Hänsch
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.
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.
18 s,\\\\,\\,g; s,\\&,\&,g;
19 s,\\<,\<,g; s,\\>,\>,g;
20 s,\\",\",g; s,\\',\',g;
21 s,\\\[,\[,g; s,\\\],\],g;
22 s,\\\.,\.,g; s,\\#,\#,g;
28 H; s;^(.*)--].*$;\1-->;p;
29 g; s;^.*--]([^\n]*)$;\1;
30 x; s;^</!-->\n(.*)\n[^\n]*$;\1;; x;
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;
46 s;\[!([^]\[]*)\];<!\1>;g;
47 s;\[!--([^]\[]*)--\];<!--\1-->;g;
50 s;\[([^]\[< \t]+)([^]\[]*)\];<\1>\2</\1>;g;
55 s;^([^]\n]*)\]([^\n]*)\n([^\n]+);\1\3\2;
57 h; s;^([^\n]*)\n;;; x; s;\n.*$;;;
60 s;^([^\[\n]*)\[([^]\[< \t\n]+)([^\n]*);\1<\2>\3\n</\2>;
62 G; h; s;^[^\n]*\n+;;; x; s;\n.*$;;;
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;
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;
75 s;(<[^/][^>]*>)[ \t]*\.[ \t];\1;g;
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;