else
return Qnil;
}
+ else if (node->type == XML_COMMENT_NODE)
+ {
+ if (node->content)
+ return list3 (intern ("comment"), Qnil,
+ build_string ((char *) node->content));
+ else
+ return Qnil;
+ }
else
return Qnil;
}
parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp)
{
xmlDoc *doc;
- xmlNode *node;
Lisp_Object result = Qnil;
const char *burl = "";
- EMACS_INT bytes;
- EMACS_INT istart, iend;
+ ptrdiff_t bytes;
+ ptrdiff_t istart, iend;
LIBXML_TEST_VERSION;
doc = xmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)),
bytes, burl, "utf-8",
XML_PARSE_NONET|XML_PARSE_NOWARNING|
- XML_PARSE_NOERROR);
+ XML_PARSE_NOBLANKS |XML_PARSE_NOERROR);
if (doc != NULL)
{
- node = xmlDocGetRootElement (doc);
- if (node != NULL)
- result = make_dom (node);
+ /* If the document is just comments, then this should get us the
+ nodes anyway. */
+ xmlNode *n = doc->children->next;
+ Lisp_Object r = Qnil;
+
+ while (n) {
+ if (!NILP (r))
+ result = Fcons (r, result);
+ r = make_dom (n);
+ n = n->next;
+ }
+
+ if (NILP (result)) {
+ /* The document isn't just comments, so get the tree the
+ proper way. */
+ xmlNode *node = xmlDocGetRootElement (doc);
+ if (node != NULL)
+ result = make_dom (node);
+ } else
+ result = Fcons (intern ("top"),
+ Fcons (Qnil, Fnreverse (Fcons (r, result))));
+
xmlFreeDoc (doc);
- xmlCleanupParser ();
}
return result;