1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Prepare the CSS scanner for parsing [foo{|,*,^,$,}=bar] selectors

This commit is contained in:
Jonas Fonseca 2005-12-13 04:50:30 +01:00 committed by Jonas Fonseca
parent 5ff0849eb3
commit 771a2eea82
2 changed files with 35 additions and 4 deletions

View File

@ -43,12 +43,12 @@ static const struct scan_table_info css_scan_table_info[] = {
SCAN_TABLE_STRING(" \f\n\r\t\v\000", CSS_CHAR_WHITESPACE),
SCAN_TABLE_STRING("\f\n\r", CSS_CHAR_NEWLINE),
SCAN_TABLE_STRING("-", CSS_CHAR_IDENT),
SCAN_TABLE_STRING(".#@!\"'<-/", CSS_CHAR_TOKEN_START),
SCAN_TABLE_STRING(".#@!\"'<-/|^$*", CSS_CHAR_TOKEN_START),
/* Unicode escape (that we do not handle yet) + other special chars */
SCAN_TABLE_STRING("\\_*", CSS_CHAR_IDENT | CSS_CHAR_IDENT_START),
SCAN_TABLE_STRING("\\_", CSS_CHAR_IDENT | CSS_CHAR_IDENT_START),
/* This should contain mostly used char tokens like ':' and maybe a few
* garbage chars that people might put in their CSS code */
SCAN_TABLE_STRING("({});:,.>", CSS_CHAR_TOKEN),
SCAN_TABLE_STRING("[({})];:,.>", CSS_CHAR_TOKEN),
SCAN_TABLE_STRING("<![CDATA]->", CSS_CHAR_SGML_MARKUP),
SCAN_TABLE_END,
@ -259,6 +259,32 @@ scan_css_token(struct scanner *scanner, struct scanner_token *token)
CSS_TOKEN_AT_KEYWORD);
}
} else if (first_char == '*') {
if (*string == '=') {
type = CSS_TOKEN_SELECT_CONTAINS;
string++;
} else {
type = CSS_TOKEN_IDENT;
}
} else if (first_char == '^') {
if (*string == '=') {
type = CSS_TOKEN_SELECT_BEGIN;
string++;
}
} else if (first_char == '$') {
if (*string == '=') {
type = CSS_TOKEN_SELECT_END;
string++;
}
} else if (first_char == '|') {
if (*string == '=') {
type = CSS_TOKEN_SELECT_HYPHEN_LIST;
string++;
}
} else if (first_char == '!') {
scan_css(scanner, string, CSS_CHAR_WHITESPACE);
if (!strncasecmp(string, "important", 9)) {

View File

@ -69,7 +69,12 @@ enum css_token_type {
CSS_TOKEN_IMPORTANT, /* !<whitespace>important */
/* TODO: Selector stuff like "|=" and "~=" */
/* TODO: Selector stuff: */
CSS_TOKEN_SELECT_SPACE_LIST, /* ~= */
CSS_TOKEN_SELECT_HYPHEN_LIST, /* |= */
CSS_TOKEN_SELECT_BEGIN, /* ^= */
CSS_TOKEN_SELECT_END, /* $= */
CSS_TOKEN_SELECT_CONTAINS, /* *= */
/* Special tokens: */