- HTMLtree.h: cleanup and started evaluating the work needed on
revamping the HTML output code
Daniel
diff --git a/HTMLtree.c b/HTMLtree.c
index b59b427..c10aac1 100644
--- a/HTMLtree.c
+++ b/HTMLtree.c
@@ -10,8 +10,6 @@
#include "libxml.h"
#ifdef LIBXML_HTML_ENABLED
-#include <string.h> /* for memset() only ! */
-
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
@@ -182,26 +180,6 @@
*/
while (cur != NULL) {
if (cur->name != NULL) {
-/*
- if (xmlStrEqual(cur->name, BAD_CAST"html"))
- break;
- if (xmlStrEqual(cur->name, BAD_CAST"body")) {
- if (encoding == NULL)
- return(0);
- meta = xmlNewDocNode(doc, NULL, BAD_CAST"head", NULL);
- xmlAddPrevSibling(cur, meta);
- cur = meta;
- meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL);
- xmlAddChild(cur, meta);
- xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
- xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
- return(0);
- }
- if (xmlStrEqual(cur->name, BAD_CAST"head"))
- goto found_head;
- if (xmlStrEqual(cur->name, BAD_CAST"meta"))
- goto found_meta;
-*/
if (xmlStrcasecmp(cur->name, BAD_CAST"html") == 0)
break;
if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
@@ -220,24 +198,6 @@
*/
while (cur != NULL) {
if (cur->name != NULL) {
-/*
- if (xmlStrEqual(cur->name, BAD_CAST"head"))
- break;
- if (xmlStrEqual(cur->name, BAD_CAST"body")) {
- if (encoding == NULL)
- return(0);
- meta = xmlNewDocNode(doc, NULL, BAD_CAST"head", NULL);
- xmlAddPrevSibling(cur, meta);
- cur = meta;
- meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL);
- xmlAddChild(cur, meta);
- xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
- xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
- return(0);
- }
- if (xmlStrEqual(cur->name, BAD_CAST"meta"))
- goto found_meta;
-*/
if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
break;
if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0)
@@ -381,6 +341,12 @@
htmlAttrDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
xmlChar *value;
+ /*
+ * TODO: The html output method should not escape a & character
+ * occurring in an attribute value immediately followed by
+ * a { character (see Section B.7.1 of the HTML 4.0 Recommendation).
+ */
+
if (cur == NULL) {
xmlGenericError(xmlGenericErrorContext,
"htmlAttrDump : property == NULL\n");
@@ -561,7 +527,8 @@
}
if ((cur->content == NULL) && (cur->children == NULL)) {
if ((info != NULL) && (info->saveEndTag != 0) &&
- (strcmp(info->name, "html")) && (strcmp(info->name, "body"))) {
+ (xmlStrcmp(BAD_CAST info->name, BAD_CAST "html")) &&
+ (xmlStrcmp(BAD_CAST info->name, BAD_CAST "body"))) {
xmlBufferWriteChar(buf, ">");
} else {
xmlBufferWriteChar(buf, "></");
@@ -745,7 +712,7 @@
************************************************************************/
/**
- * htmlDtdDump:
+ * htmlDtdDumpOutput:
* @buf: the HTML buffer output
* @doc: the document
* @encoding: the encoding string
@@ -781,7 +748,7 @@
}
/**
- * htmlAttrDump:
+ * htmlAttrDumpOutput:
* @buf: the HTML buffer output
* @doc: the document
* @cur: the attribute pointer
@@ -794,6 +761,12 @@
const char *encoding ATTRIBUTE_UNUSED) {
xmlChar *value;
+ /*
+ * TODO: The html output method should not escape a & character
+ * occurring in an attribute value immediately followed by
+ * a { character (see Section B.7.1 of the HTML 4.0 Recommendation).
+ */
+
if (cur == NULL) {
xmlGenericError(xmlGenericErrorContext,
"htmlAttrDump : property == NULL\n");
@@ -814,7 +787,7 @@
}
/**
- * htmlAttrListDump:
+ * htmlAttrListDumpOutput:
* @buf: the HTML buffer output
* @doc: the document
* @cur: the first attribute pointer
@@ -840,7 +813,7 @@
xmlNodePtr cur, const char *encoding);
/**
- * htmlNodeListDump:
+ * htmlNodeListDumpOutput:
* @buf: the HTML buffer output
* @doc: the document
* @cur: the first node
@@ -984,7 +957,8 @@
}
if ((cur->content == NULL) && (cur->children == NULL)) {
if ((info != NULL) && (info->saveEndTag != 0) &&
- (strcmp(info->name, "html")) && (strcmp(info->name, "body"))) {
+ (xmlStrcmp(BAD_CAST info->name, BAD_CAST "html")) &&
+ (xmlStrcmp(BAD_CAST info->name, BAD_CAST "body"))) {
xmlOutputBufferWriteString(buf, ">");
} else {
xmlOutputBufferWriteString(buf, "></");
@@ -1040,7 +1014,7 @@
}
/**
- * htmlDocContentDump:
+ * htmlDocContentDumpOutput:
* @buf: the HTML buffer output
* @cur: the document
* @encoding: the encoding string
@@ -1048,7 +1022,8 @@
* Dump an HTML document.
*/
void
-htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding) {
+htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
+ const char *encoding) {
int type;
/*