1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

- HTMLtree.h: cleanup and started evaluating the work needed on

revamping the HTML output code
Daniel
This commit is contained in:
Daniel Veillard
2001-06-13 07:45:41 +00:00
parent 84666b3831
commit eca60d07f2
2 changed files with 28 additions and 48 deletions

View File

@ -1,3 +1,8 @@
Wed Jun 13 09:44:15 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* HTMLtree.h: cleanup and started evaluating the work needed on
revamping the HTML output code
Mon Jun 11 19:29:40 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Mon Jun 11 19:29:40 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* DOCBparser.c: handling of PIs and <?sgml-declaration in entities. * DOCBparser.c: handling of PIs and <?sgml-declaration in entities.

View File

@ -10,8 +10,6 @@
#include "libxml.h" #include "libxml.h"
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
#include <string.h> /* for memset() only ! */
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
#include <ctype.h> #include <ctype.h>
#endif #endif
@ -182,26 +180,6 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
*/ */
while (cur != NULL) { while (cur != NULL) {
if (cur->name != 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) if (xmlStrcasecmp(cur->name, BAD_CAST"html") == 0)
break; break;
if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0) if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
@ -220,24 +198,6 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
*/ */
while (cur != NULL) { while (cur != NULL) {
if (cur->name != 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) if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
break; break;
if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0)
@ -381,6 +341,12 @@ static void
htmlAttrDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) { htmlAttrDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
xmlChar *value; 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) { if (cur == NULL) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"htmlAttrDump : property == NULL\n"); "htmlAttrDump : property == NULL\n");
@ -561,7 +527,8 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
} }
if ((cur->content == NULL) && (cur->children == NULL)) { if ((cur->content == NULL) && (cur->children == NULL)) {
if ((info != NULL) && (info->saveEndTag != 0) && 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, ">"); xmlBufferWriteChar(buf, ">");
} else { } else {
xmlBufferWriteChar(buf, "></"); xmlBufferWriteChar(buf, "></");
@ -745,7 +712,7 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
************************************************************************/ ************************************************************************/
/** /**
* htmlDtdDump: * htmlDtdDumpOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @doc: the document * @doc: the document
* @encoding: the encoding string * @encoding: the encoding string
@ -781,7 +748,7 @@ htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
} }
/** /**
* htmlAttrDump: * htmlAttrDumpOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @doc: the document * @doc: the document
* @cur: the attribute pointer * @cur: the attribute pointer
@ -794,6 +761,12 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
const char *encoding ATTRIBUTE_UNUSED) { const char *encoding ATTRIBUTE_UNUSED) {
xmlChar *value; 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) { if (cur == NULL) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"htmlAttrDump : property == NULL\n"); "htmlAttrDump : property == NULL\n");
@ -814,7 +787,7 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
} }
/** /**
* htmlAttrListDump: * htmlAttrListDumpOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @doc: the document * @doc: the document
* @cur: the first attribute pointer * @cur: the first attribute pointer
@ -840,7 +813,7 @@ void htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
xmlNodePtr cur, const char *encoding); xmlNodePtr cur, const char *encoding);
/** /**
* htmlNodeListDump: * htmlNodeListDumpOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @doc: the document * @doc: the document
* @cur: the first node * @cur: the first node
@ -984,7 +957,8 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
} }
if ((cur->content == NULL) && (cur->children == NULL)) { if ((cur->content == NULL) && (cur->children == NULL)) {
if ((info != NULL) && (info->saveEndTag != 0) && 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, ">"); xmlOutputBufferWriteString(buf, ">");
} else { } else {
xmlOutputBufferWriteString(buf, "></"); xmlOutputBufferWriteString(buf, "></");
@ -1040,7 +1014,7 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
} }
/** /**
* htmlDocContentDump: * htmlDocContentDumpOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @cur: the document * @cur: the document
* @encoding: the encoding string * @encoding: the encoding string
@ -1048,7 +1022,8 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
* Dump an HTML document. * Dump an HTML document.
*/ */
void void
htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding) { htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
const char *encoding) {
int type; int type;
/* /*