diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 78a105db..f7cfc811 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -811,6 +811,7 @@ render_dom_document(struct cache_entry *cached, struct document *document, struct dom_renderer renderer; struct conv_table *convert_table; struct sgml_parser *parser; + enum sgml_document_type doctype; assert(document->options.plain); @@ -824,7 +825,13 @@ render_dom_document(struct cache_entry *cached, struct document *document, document->bgcolor = document->options.default_bg; - parser = init_sgml_parser(SGML_PARSER_STREAM, SGML_DOCTYPE_HTML, + if (cached->content_type + && !strlcasecmp("application/rss+xml", 19, cached->content_type, -1)) + doctype = SGML_DOCTYPE_RSS; + else + doctype = SGML_DOCTYPE_HTML; + + parser = init_sgml_parser(SGML_PARSER_STREAM, doctype, &renderer, cached->uri, dom_source_renderer_push_callbacks, dom_source_renderer_pop_callbacks); diff --git a/src/document/renderer.c b/src/document/renderer.c index 07e53bfe..b0f3ff84 100644 --- a/src/document/renderer.c +++ b/src/document/renderer.c @@ -19,6 +19,7 @@ #include "document/html/renderer.h" #include "document/plain/renderer.h" #include "document/renderer.h" +#include "document/rss/renderer.h" #include "document/view.h" #include "ecmascript/ecmascript.h" #include "encoding/encoding.h" @@ -241,7 +242,8 @@ render_encoded_document(struct cache_entry *cached, struct document *document) if (document->options.plain) { #ifdef CONFIG_DOM if (cached->content_type - && !strlcasecmp("text/html", 9, cached->content_type, -1)) + && (!strlcasecmp("text/html", 9, cached->content_type, -1) + || !strlcasecmp("application/rss+xml", 19, cached->content_type, -1))) render_dom_document(cached, document, &buffer); else #endif diff --git a/src/document/sgml/Makefile b/src/document/sgml/Makefile index c2b71541..23dceb31 100644 --- a/src/document/sgml/Makefile +++ b/src/document/sgml/Makefile @@ -1,7 +1,7 @@ top_builddir=../../.. include $(top_builddir)/Makefile.config -SUBDIRS = html +SUBDIRS = html rss OBJS = sgml.o parser.o scanner.o include $(top_srcdir)/Makefile.lib diff --git a/src/document/sgml/rss/attribute.inc b/src/document/sgml/rss/attribute.inc new file mode 100644 index 00000000..b535cdb4 --- /dev/null +++ b/src/document/sgml/rss/attribute.inc @@ -0,0 +1,3 @@ +/* RSS attributes */ + +RSS_(ATTRIBUTE, ISPERMALINK, 0), diff --git a/src/document/sgml/rss/element.inc b/src/document/sgml/rss/element.inc new file mode 100644 index 00000000..748596f6 --- /dev/null +++ b/src/document/sgml/rss/element.inc @@ -0,0 +1,10 @@ +/* RSS elements */ + +RSS_(ELEMENT, CHANNEL, 0), +RSS_(ELEMENT, ITEM, 0), +RSS_(ELEMENT, TITLE, 0), +RSS_(ELEMENT, AUTHOR, 0), +RSS_(ELEMENT, PUBDATE, 0), +RSS_(ELEMENT, GUID, 0), +RSS_(ELEMENT, LINK, 0), +RSS_(ELEMENT, DESCRIPTION, 0), diff --git a/src/document/sgml/rss/rss.c b/src/document/sgml/rss/rss.c new file mode 100644 index 00000000..907fec4e --- /dev/null +++ b/src/document/sgml/rss/rss.c @@ -0,0 +1,35 @@ +/* SGML node handling */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "elinks.h" + +#include "document/sgml/rss/rss.h" +#include "document/sgml/sgml.h" + + +#define RSS_(node, name, id) SGML_NODE_INFO(RSS, node, name, id) + +static struct sgml_node_info rss_attributes[RSS_ATTRIBUTES] = { + SGML_NODE_HEAD(RSS, ATTRIBUTE), + +#include "document/sgml/rss/attribute.inc" +}; + +static struct sgml_node_info rss_elements[RSS_ELEMENTS] = { + SGML_NODE_HEAD(RSS, ELEMENT), + +#include "document/sgml/rss/element.inc" +}; + + +struct sgml_info sgml_rss_info = { + SGML_DOCTYPE_RSS, + rss_attributes, + rss_elements, +}; diff --git a/src/document/sgml/rss/rss.h b/src/document/sgml/rss/rss.h new file mode 100644 index 00000000..e011ef81 --- /dev/null +++ b/src/document/sgml/rss/rss.h @@ -0,0 +1,28 @@ +#ifndef EL__DOCUMENT_SGML_RSS_RSS_H +#define EL__DOCUMENT_SGML_RSS_RSS_H + +#include "document/sgml/sgml.h" + +extern struct sgml_info sgml_rss_info; + +#define RSS_(node, name, flags) SGML_NODE_INFO_TYPE(RSS, node, name) + +enum rss_element_type { + RSS_ELEMENT_UNKNOWN, + +#include "document/sgml/rss/element.inc" + + RSS_ELEMENTS, +}; + +enum rss_attribute_type { + RSS_ATTRIBUTE_UNKNOWN, + +#include "document/sgml/rss/attribute.inc" + + RSS_ATTRIBUTES, +}; + +#undef RSS_ + +#endif diff --git a/src/document/sgml/sgml.c b/src/document/sgml/sgml.c index 55be6958..da44adb1 100644 --- a/src/document/sgml/sgml.c +++ b/src/document/sgml/sgml.c @@ -17,6 +17,7 @@ /* Backend includes: */ #include "document/sgml/html/html.h" +#include "document/sgml/rss/rss.h" int @@ -30,6 +31,7 @@ sgml_info_strcmp(const void *key_, const void *node_) struct sgml_info *sgml_info[SGML_DOCTYPES] = { &sgml_html_info, + &sgml_rss_info, }; struct sgml_info * diff --git a/src/document/sgml/sgml.h b/src/document/sgml/sgml.h index 863043a0..f1d7eb53 100644 --- a/src/document/sgml/sgml.h +++ b/src/document/sgml/sgml.h @@ -77,6 +77,7 @@ get_sgml_node_info(struct sgml_node_info list[], struct dom_node *node) enum sgml_document_type { SGML_DOCTYPE_HTML, + SGML_DOCTYPE_RSS, SGML_DOCTYPES, }; diff --git a/src/session/download.c b/src/session/download.c index 924be1d6..88ab0268 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -1146,6 +1146,7 @@ struct { } static known_types[] = { { "text/html", 0 }, { "application/xhtml+xml", 0 }, /* RFC 3236 */ + { "application/rss+xml", 0 }, { "text/plain", 1 }, { NULL, 1 }, };