[xml] patch: support <embed> in HTML parser



Hi,

Here is a patch to extend the HTML parser to support the <embed> element, which is not in standard HTML but is widely used on the web.

It seems to work for me, but it would be good if someone could check that I got the magic numbers right in the HTML element array.

Best regards,

Michael

Index: HTMLparser.c
===================================================================
--- HTMLparser.c        (revision 3603)
+++ HTMLparser.c        (working copy)
@@ -472,8 +472,8 @@
 #define NB_FONTSTYLE 8
#define PHRASE "em", "strong", "dfn", "code", "samp", "kbd", "var", "cite", "abbr", "acronym"
 #define NB_PHRASE 10
-#define SPECIAL "a", "img", "applet", "object", "font", "basefont", "br", "script", "map", "q", "sub", "sup", "span", "bdo", "iframe"
-#define NB_SPECIAL 15
+#define SPECIAL "a", "img", "applet", "embed", "object", "font", "basefont", "br", "script", "map", "q", "sub", "sup", "span", "bdo", "iframe"
+#define NB_SPECIAL 16
 #define INLINE PCDATA FONTSTYLE PHRASE SPECIAL FORMCTRL
#define NB_INLINE NB_PCDATA + NB_FONTSTYLE + NB_PHRASE + NB_SPECIAL + NB_FORMCTRL #define BLOCK HEADING, LIST "pre", "p", "dl", "div", "center", "noscript", "noframes", "blockquote", "form", "isindex", "hr", "table", "fieldset", "address"
@@ -572,6 +572,7 @@
static const char* const html_content[] = { "head", "body", "frameset", NULL } ; static const char* const iframe_attrs[] = { COREATTRS, "longdesc", "name", "src", "frameborder", "marginwidth", "marginheight", "scrolling", "align", "height", "width", NULL } ; static const char* const img_attrs[] = { ATTRS, "longdesc", "name", "height", "width", "usemap", "ismap", NULL } ; +static const char* const embed_attrs[] = { COREATTRS, "align", "alt", "border", "code", "codebase", "frameborder", "height", "hidden", "hspace", "name", "palette", "pluginspace", "pluginurl", "src", "type", "units", "vspace", "width", NULL } ; static const char* const input_attrs[] = { ATTRS, "type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "ismap", "tabindex", "accesskey", "onfocus", "onblur", "onselect", "onchange", "accept", NULL } ; static const char* const prompt_attrs[] = { COREATTRS, I18N, "prompt", NULL } ; static const char* const label_attrs[] = { ATTRS, "for", "accesskey", "onfocus", "onblur", NULL } ;
@@ -706,6 +707,9 @@
 { "em",              0, 3, 0, 0, 0, 0, 1, "emphasis",
        DECL html_inline, NULL, DECL html_attrs, NULL, NULL
 },
+{ "embed",   0, 2, 2, 1, 0, 0, 1, "generic embedded object ",
+       EMPTY, NULL, DECL embed_attrs, NULL, NULL
+},
 { "fieldset",        0, 0, 0, 0, 0, 0, 0, "form control group ",
        DECL fieldset_contents , NULL, DECL html_attrs, NULL, NULL
 },
Index: HTMLparser.c
===================================================================
--- HTMLparser.c        (revision 3603)
+++ HTMLparser.c        (working copy)
@@ -472,8 +472,8 @@
 #define NB_FONTSTYLE 8
 #define PHRASE "em", "strong", "dfn", "code", "samp", "kbd", "var", "cite", "abbr", "acronym"
 #define NB_PHRASE 10
-#define SPECIAL "a", "img", "applet", "object", "font", "basefont", "br", "script", "map", "q", "sub", 
"sup", "span", "bdo", "iframe"
-#define NB_SPECIAL 15
+#define SPECIAL "a", "img", "applet", "embed", "object", "font", "basefont", "br", "script", "map", "q", 
"sub", "sup", "span", "bdo", "iframe"
+#define NB_SPECIAL 16
 #define INLINE PCDATA FONTSTYLE PHRASE SPECIAL FORMCTRL
 #define NB_INLINE NB_PCDATA + NB_FONTSTYLE + NB_PHRASE + NB_SPECIAL + NB_FORMCTRL
 #define BLOCK HEADING, LIST "pre", "p", "dl", "div", "center", "noscript", "noframes", "blockquote", "form", 
"isindex", "hr", "table", "fieldset", "address"
@@ -572,6 +572,7 @@
 static const char* const html_content[] = { "head", "body", "frameset", NULL } ;
 static const char* const iframe_attrs[] = { COREATTRS, "longdesc", "name", "src", "frameborder", 
"marginwidth", "marginheight", "scrolling", "align", "height", "width", NULL } ;
 static const char* const img_attrs[] = { ATTRS, "longdesc", "name", "height", "width", "usemap", "ismap", 
NULL } ;
+static const char* const embed_attrs[] = { COREATTRS, "align", "alt", "border", "code", "codebase", 
"frameborder", "height", "hidden", "hspace", "name", "palette", "pluginspace", "pluginurl", "src", "type", 
"units", "vspace", "width", NULL } ;
 static const char* const input_attrs[] = { ATTRS, "type", "name", "value", "checked", "disabled", 
"readonly", "size", "maxlength", "src", "alt", "usemap", "ismap", "tabindex", "accesskey", "onfocus", 
"onblur", "onselect", "onchange", "accept", NULL } ;
 static const char* const prompt_attrs[] = { COREATTRS, I18N, "prompt", NULL } ;
 static const char* const label_attrs[] = { ATTRS, "for", "accesskey", "onfocus", "onblur", NULL } ;
@@ -706,6 +707,9 @@
 { "em",                0, 3, 0, 0, 0, 0, 1, "emphasis",
        DECL html_inline, NULL, DECL html_attrs, NULL, NULL
 },
+{ "embed",     0, 2, 2, 1, 0, 0, 1, "generic embedded object ",
+       EMPTY, NULL, DECL embed_attrs, NULL, NULL
+},
 { "fieldset",  0, 0, 0, 0, 0, 0, 0, "form control group ",
        DECL fieldset_contents , NULL, DECL html_attrs, NULL, NULL
 },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]