mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
Make the SGML parser ready for (specializing) doctypes other than HTML
This commit is contained in:
parent
f6e551379e
commit
ceffe8f1a4
@ -824,7 +824,8 @@ render_dom_document(struct cache_entry *cached, struct document *document,
|
||||
|
||||
document->bgcolor = document->options.default_bg;
|
||||
|
||||
parser = init_sgml_parser(SGML_PARSER_STREAM, &renderer, cached->uri,
|
||||
parser = init_sgml_parser(SGML_PARSER_STREAM, SGML_DOCTYPE_HTML,
|
||||
&renderer, cached->uri,
|
||||
dom_source_renderer_push_callbacks,
|
||||
dom_source_renderer_pop_callbacks);
|
||||
if (!parser) return;
|
||||
|
@ -31,6 +31,7 @@ static struct sgml_node_info html_elements[HTML_ELEMENTS] = {
|
||||
|
||||
|
||||
struct sgml_info sgml_html_info = {
|
||||
SGML_DOCTYPE_HTML,
|
||||
html_attributes,
|
||||
html_elements,
|
||||
};
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "document/dom/node.h"
|
||||
#include "document/dom/stack.h"
|
||||
#include "document/sgml/html/html.h"
|
||||
#include "document/sgml/parser.h"
|
||||
#include "document/sgml/scanner.h"
|
||||
#include "document/sgml/sgml.h"
|
||||
@ -305,7 +304,8 @@ parse_sgml_document(struct dom_stack *stack, struct scanner *scanner)
|
||||
|
||||
|
||||
struct sgml_parser *
|
||||
init_sgml_parser(enum sgml_parser_type type, void *data, struct uri *uri,
|
||||
init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype,
|
||||
void *data, struct uri *uri,
|
||||
dom_stack_callback_T push_callbacks[DOM_NODES],
|
||||
dom_stack_callback_T pop_callbacks[DOM_NODES])
|
||||
{
|
||||
@ -317,7 +317,7 @@ init_sgml_parser(enum sgml_parser_type type, void *data, struct uri *uri,
|
||||
|
||||
parser->type = type;
|
||||
parser->uri = get_uri_reference(uri);
|
||||
parser->info = &sgml_html_info;
|
||||
parser->info = get_sgml_info(doctype);
|
||||
parser->data = data;
|
||||
|
||||
init_dom_stack(&parser->stack, parser,
|
||||
|
@ -43,7 +43,8 @@ struct sgml_parser_state {
|
||||
};
|
||||
|
||||
struct sgml_parser *
|
||||
init_sgml_parser(enum sgml_parser_type type, void *data, struct uri *uri,
|
||||
init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype,
|
||||
void *data, struct uri *uri,
|
||||
dom_stack_callback_T push_callbacks[DOM_NODES],
|
||||
dom_stack_callback_T pop_callbacks[DOM_NODES]);
|
||||
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include "util/error.h"
|
||||
#include "util/string.h"
|
||||
|
||||
/* Backend includes: */
|
||||
|
||||
#include "document/sgml/html/html.h"
|
||||
|
||||
|
||||
int
|
||||
sgml_info_strcmp(const void *key_, const void *node_)
|
||||
@ -23,3 +27,13 @@ sgml_info_strcmp(const void *key_, const void *node_)
|
||||
|
||||
return dom_string_casecmp(&key->string, &node->string);
|
||||
}
|
||||
|
||||
struct sgml_info *sgml_info[SGML_DOCTYPES] = {
|
||||
&sgml_html_info,
|
||||
};
|
||||
|
||||
struct sgml_info *
|
||||
get_sgml_info(enum sgml_document_type doctype)
|
||||
{
|
||||
return doctype < SGML_DOCTYPES ? sgml_info[doctype] : NULL;
|
||||
}
|
||||
|
@ -75,9 +75,18 @@ get_sgml_node_info(struct sgml_node_info list[], struct dom_node *node)
|
||||
return match ? match : list;
|
||||
}
|
||||
|
||||
enum sgml_document_type {
|
||||
SGML_DOCTYPE_HTML,
|
||||
|
||||
SGML_DOCTYPES,
|
||||
};
|
||||
|
||||
struct sgml_info {
|
||||
enum sgml_document_type doctype;
|
||||
struct sgml_node_info *attributes;
|
||||
struct sgml_node_info *elements;
|
||||
};
|
||||
|
||||
struct sgml_info *get_sgml_info(enum sgml_document_type doctype);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user