* htmlNodeDumpFormatOutput: * @buf: the HTML buffer output * @doc: the document * @cur: the current node * @encoding: the encoding string * @format: should formatting spaces been added * * Dump an HTML node, recursive behaviour,children are printed too. */
| 761 | * Dump an HTML node, recursive behaviour,children are printed too. |
| 762 | */ |
| 763 | void |
| 764 | htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, |
| 765 | xmlNodePtr cur, const char *encoding, int format) { |
| 766 | const htmlElemDesc * info; |
| 767 | |
| 768 | xmlInitParser(); |
| 769 | |
| 770 | if ((cur == NULL) || (buf == NULL)) { |
| 771 | return; |
| 772 | } |
| 773 | /* |
| 774 | * Special cases. |
| 775 | */ |
| 776 | if (cur->type == XML_DTD_NODE) |
| 777 | return; |
| 778 | if ((cur->type == XML_HTML_DOCUMENT_NODE) || |
| 779 | (cur->type == XML_DOCUMENT_NODE)){ |
| 780 | htmlDocContentDumpOutput(buf, (xmlDocPtr) cur, encoding); |
| 781 | return; |
| 782 | } |
| 783 | if (cur->type == XML_ATTRIBUTE_NODE) { |
| 784 | htmlAttrDumpOutput(buf, doc, (xmlAttrPtr) cur, encoding); |
| 785 | return; |
| 786 | } |
| 787 | if (cur->type == HTML_TEXT_NODE) { |
| 788 | if (cur->content != NULL) { |
| 789 | if (((cur->name == (const xmlChar *)xmlStringText) || |
| 790 | (cur->name != (const xmlChar *)xmlStringTextNoenc)) && |
| 791 | ((cur->parent == NULL) || |
| 792 | ((xmlStrcasecmp(cur->parent->name, BAD_CAST "script")) && |
| 793 | (xmlStrcasecmp(cur->parent->name, BAD_CAST "style"))))) { |
| 794 | xmlChar *buffer; |
| 795 | |
| 796 | buffer = xmlEncodeEntitiesReentrant(doc, cur->content); |
| 797 | if (buffer != NULL) { |
| 798 | xmlOutputBufferWriteString(buf, (const char *)buffer); |
| 799 | xmlFree(buffer); |
| 800 | } |
| 801 | } else { |
| 802 | xmlOutputBufferWriteString(buf, (const char *)cur->content); |
| 803 | } |
| 804 | } |
| 805 | return; |
| 806 | } |
| 807 | if (cur->type == HTML_COMMENT_NODE) { |
| 808 | if (cur->content != NULL) { |
| 809 | xmlOutputBufferWriteString(buf, "<!--"); |
| 810 | xmlOutputBufferWriteString(buf, (const char *)cur->content); |
| 811 | xmlOutputBufferWriteString(buf, "-->"); |
| 812 | } |
| 813 | return; |
| 814 | } |
| 815 | if (cur->type == HTML_PI_NODE) { |
| 816 | if (cur->name == NULL) |
| 817 | return; |
| 818 | xmlOutputBufferWriteString(buf, "<?"); |
| 819 | xmlOutputBufferWriteString(buf, (const char *)cur->name); |
| 820 | if (cur->content != NULL) { |