mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-25 23:21:26 +03:00
- HTMLtree.[ch]: more work on the HTML serialization routnes,
cleanup, encoding support. Daniel
This commit is contained in:
parent
608ad0791b
commit
c4f631d28a
@ -1,3 +1,8 @@
|
||||
Fri Jun 15 07:08:57 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* HTMLtree.[ch]: more work on the HTML serialization routnes,
|
||||
cleanup, encoding support.
|
||||
|
||||
Thu Jun 14 10:31:17 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* xpath.c: Thomas Broyer suggested a better patch for the / arg
|
||||
|
54
HTMLtree.c
54
HTMLtree.c
@ -294,6 +294,9 @@ found_meta:
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
void htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
||||
xmlNodePtr cur, const char *encoding, int format);
|
||||
|
||||
static void
|
||||
htmlDocContentDump(xmlBufferPtr buf, xmlDocPtr cur, int format);
|
||||
|
||||
@ -616,18 +619,46 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
||||
*
|
||||
* Dump an HTML node, recursive behaviour,children are printed too.
|
||||
*
|
||||
* TODO: handle the encoding not used yet
|
||||
* TODO: if encoding == NULL try to save in the doc encoding
|
||||
*
|
||||
* returns: the number of byte written or -1 in case of failure.
|
||||
*/
|
||||
void
|
||||
htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc, xmlNodePtr cur,
|
||||
const char *encoding ATTRIBUTE_UNUSED, int format) {
|
||||
xmlBufferPtr buf;
|
||||
int
|
||||
htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
|
||||
xmlNodePtr cur, const char *encoding, int format) {
|
||||
xmlOutputBufferPtr buf;
|
||||
xmlCharEncodingHandlerPtr handler = NULL;
|
||||
int ret;
|
||||
|
||||
buf = xmlBufferCreate();
|
||||
if (buf == NULL) return;
|
||||
htmlNodeDumpFormat(buf, doc, cur, format);
|
||||
xmlBufferDump(out, buf);
|
||||
xmlBufferFree(buf);
|
||||
if (encoding != NULL) {
|
||||
xmlCharEncoding enc;
|
||||
|
||||
enc = xmlParseCharEncoding(encoding);
|
||||
if (enc != XML_CHAR_ENCODING_UTF8) {
|
||||
handler = xmlFindCharEncodingHandler(encoding);
|
||||
if (handler == NULL)
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fallback to HTML or ASCII when the encoding is unspecified
|
||||
*/
|
||||
if (handler == NULL)
|
||||
handler = xmlFindCharEncodingHandler("HTML");
|
||||
if (handler == NULL)
|
||||
handler = xmlFindCharEncodingHandler("ascii");
|
||||
|
||||
/*
|
||||
* save the content to a temp buffer.
|
||||
*/
|
||||
buf = xmlOutputBufferCreateFile(out, handler);
|
||||
if (buf == NULL) return(0);
|
||||
|
||||
htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format);
|
||||
|
||||
ret = xmlOutputBufferClose(buf);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -862,9 +893,6 @@ htmlAttrListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, co
|
||||
void htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
||||
xmlNodePtr cur, const char *encoding);
|
||||
|
||||
void htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
||||
xmlNodePtr cur, const char *encoding, int format);
|
||||
|
||||
/**
|
||||
* htmlNodeListDumpOutput:
|
||||
* @buf: the HTML buffer output
|
||||
|
@ -75,7 +75,7 @@ void htmlNodeDump (xmlBufferPtr buf,
|
||||
void htmlNodeDumpFile (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
void htmlNodeDumpFileFormat (FILE *out,
|
||||
int htmlNodeDumpFileFormat (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
const char *encoding,
|
||||
|
@ -75,7 +75,7 @@ void htmlNodeDump (xmlBufferPtr buf,
|
||||
void htmlNodeDumpFile (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
void htmlNodeDumpFileFormat (FILE *out,
|
||||
int htmlNodeDumpFileFormat (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
const char *encoding,
|
||||
|
Loading…
Reference in New Issue
Block a user