]> git.plutz.net Git - cgilite/blobdiff - html-sh.sed
introduce . as stop sign to prevent parsing text as attributes
[cgilite] / html-sh.sed
index cb1c613185356b03eac15be9fd59967f3b769784..16aeb9a44e907814b5865fb9887fbe9833f450d8 100755 (executable)
@@ -1,4 +1,12 @@
-#!/bin/sed -nrf
+#!/bin/sed -nEf
+
+:Escapes
+s,\\\\,\\,g; s,\\&,\&,g;
+s,\\<,\&lt;,g; s,\\>,\&gt;,g;
+s,\\",\&quot;,g; s,\\',\&apos;,g;
+s,\\\[,\&#91;,g; s,\\\],\&#93;,g;
+s,\\\.,\&#46;,g; s,\\#,\&#35;,g;
+s,\\,,g;
 
 :CommentHandle
 x; /^<\/!-->/{
@@ -40,6 +48,7 @@ t tagopen;
 G; h; s;^[^\n]*\n+;;; x; s;\n.*$;;;
 
 :attribs
+s;(<[^/][^>]*)>[ \t]*\.[ \t];\1>;g; t attEnd;
 s;class="([^>]+)>[ \t]*\.([^< \t]+);class="\2 \1>;g; t attribs;
 s;(<[^/][^>]*)>[ \t]*\.([^< \t]+);\1 class="\2">;g;
 s;(<[^/][^>]*)>[ \t]*#([^< \t]+);\1 id="\2">;g;
@@ -50,6 +59,7 @@ s;(<input ([^>]+ )?type=(checkbox|"checkbox"|'checkbox')( [^>]+)?)>[ \t]*(checke
 s;(<option( [^>]+)?)>[ \t]*(checked|selected);\1 selected="selected">;g;
 s;(<select( [^>]+)?)>[ \t]*multiple;\1 multiple="multiple">;g;
 t attribs;
+:attEnd
 
 s;(<[^/][^>]*>)[ \t]*;\1;g;
 # s;(<[^/][^>]*)>[ \t]*</[^>]+>;\1/>;g;