From eaaca0513d26fa9e7cc515dbba950536c0005c06 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 13 May 2015 18:27:14 +0200 Subject: epub: Parse (and ignore) @page selector. --- source/html/css-parse.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/source/html/css-parse.c b/source/html/css-parse.c index 36ad111d..e57eb798 100644 --- a/source/html/css-parse.c +++ b/source/html/css-parse.c @@ -867,6 +867,26 @@ static fz_css_rule *parse_ruleset(struct lexbuf *buf) return fz_new_css_rule(buf->ctx, s, p); } +static fz_css_rule *parse_at_page(struct lexbuf *buf) +{ + fz_css_selector *s = NULL; + fz_css_property *p = NULL; + + white(buf); + if (accept(buf, ':')) + { + expect(buf, CSS_KEYWORD); + white(buf); + } + expect(buf, '{'); + p = parse_declaration_list(buf); + expect(buf, '}'); + white(buf); + + s = fz_new_css_selector(buf->ctx, "@page"); + return fz_new_css_rule(buf->ctx, s, p); +} + static void parse_at_rule(struct lexbuf *buf) { expect(buf, CSS_KEYWORD); @@ -920,7 +940,16 @@ static fz_css_rule *parse_stylesheet(struct lexbuf *buf, fz_css_rule *chain) { if (accept(buf, '@')) { - parse_at_rule(buf); + if (buf->lookahead == CSS_KEYWORD && !strcmp(buf->string, "page")) + { + next(buf); + rule = *nextp = parse_at_page(buf); + nextp = &rule->next; + } + else + { + parse_at_rule(buf); + } } else { -- cgit v1.2.3