mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
integrated a cleaned up version of Marc Liyanage' patch for boolean
* HTMLtree.c include/libxml/HTMLtree.h: integrated a cleaned up version of Marc Liyanage' patch for boolean attributes in HTML output Daniel
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Mon Aug 12 15:24:05 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* HTMLtree.c include/libxml/HTMLtree.h: integrated a cleaned up
|
||||||
|
version of Marc Liyanage' patch for boolean attributes in HTML
|
||||||
|
output
|
||||||
|
|
||||||
Mon Aug 12 14:11:59 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
Mon Aug 12 14:11:59 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* python/tests/serialize.py: fixed the test results, indenting
|
* python/tests/serialize.py: fixed the test results, indenting
|
||||||
|
43
HTMLtree.c
43
HTMLtree.c
@ -277,6 +277,42 @@ found_meta:
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* booleanHTMLAttrs:
|
||||||
|
*
|
||||||
|
* These are the HTML attributes which will be output
|
||||||
|
* in minimized form, i.e. <option selected="selected"> will be
|
||||||
|
* output as <option selected>, as per XSLT 1.0 16.2 "HTML Output Method"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static const char* htmlBooleanAttrs[] = {
|
||||||
|
"checked", "compact", "declare", "defer", "disabled", "ismap",
|
||||||
|
"multiple", "nohref", "noresize", "noshade", "nowrap", "readonly",
|
||||||
|
"selected", NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* htmlIsBooleanAttr:
|
||||||
|
* @name: the name of the attribute to check
|
||||||
|
*
|
||||||
|
* Determine if a given attribute is a boolean attribute.
|
||||||
|
*
|
||||||
|
* returns: false if the attribute is not boolean, true otherwise.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
htmlIsBooleanAttr(const xmlChar *name)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (htmlBooleanAttrs[i] != NULL) {
|
||||||
|
if (xmlStrcmp((const xmlChar *)htmlBooleanAttrs[i], name) == 0)
|
||||||
|
return 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Dumping HTML tree content to a simple buffer *
|
* Dumping HTML tree content to a simple buffer *
|
||||||
@ -346,7 +382,7 @@ htmlAttrDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
|
|||||||
}
|
}
|
||||||
xmlBufferWriteChar(buf, " ");
|
xmlBufferWriteChar(buf, " ");
|
||||||
xmlBufferWriteCHAR(buf, cur->name);
|
xmlBufferWriteCHAR(buf, cur->name);
|
||||||
if (cur->children != NULL) {
|
if ((cur->children != NULL) && (!htmlIsBooleanAttr(cur->name))) {
|
||||||
value = xmlNodeListGetString(doc, cur->children, 0);
|
value = xmlNodeListGetString(doc, cur->children, 0);
|
||||||
if (value) {
|
if (value) {
|
||||||
xmlBufferWriteChar(buf, "=");
|
xmlBufferWriteChar(buf, "=");
|
||||||
@ -771,6 +807,7 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
|
|||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* htmlDtdDumpOutput:
|
* htmlDtdDumpOutput:
|
||||||
* @buf: the HTML buffer output
|
* @buf: the HTML buffer output
|
||||||
@ -834,7 +871,7 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
|
|||||||
}
|
}
|
||||||
xmlOutputBufferWriteString(buf, " ");
|
xmlOutputBufferWriteString(buf, " ");
|
||||||
xmlOutputBufferWriteString(buf, (const char *)cur->name);
|
xmlOutputBufferWriteString(buf, (const char *)cur->name);
|
||||||
if (cur->children != NULL) {
|
if ((cur->children != NULL) && (!htmlIsBooleanAttr(cur->name))) {
|
||||||
value = xmlNodeListGetString(doc, cur->children, 0);
|
value = xmlNodeListGetString(doc, cur->children, 0);
|
||||||
if (value) {
|
if (value) {
|
||||||
xmlOutputBufferWriteString(buf, "=");
|
xmlOutputBufferWriteString(buf, "=");
|
||||||
@ -1330,4 +1367,6 @@ htmlSaveFileEnc(const char *filename, xmlDocPtr cur, const char *encoding) {
|
|||||||
return(htmlSaveFileFormat(filename, cur, encoding, 1));
|
return(htmlSaveFileFormat(filename, cur, encoding, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* LIBXML_HTML_ENABLED */
|
#endif /* LIBXML_HTML_ENABLED */
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML_TEXT_NODE:
|
* HTML_TEXT_NODE:
|
||||||
*
|
*
|
||||||
@ -100,6 +101,11 @@ void htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf,
|
|||||||
xmlDocPtr cur,
|
xmlDocPtr cur,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
int format);
|
int format);
|
||||||
|
|
||||||
|
int htmlIsBooleanAttr (const xmlChar *name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user