Skip to content

Commit 2117221

Browse files
committed
Update the non-ascii definition.
1 parent aa45c3c commit 2117221

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Standards-Based CSS Parser
22
==========================
33

44
This project implements a standards-based CSS Parser.
5-
I'm writing the CSS Syntax spec <http://dev.w3.org/csswg/css-syntax/>,
5+
I'm the editor of the CSS Syntax spec <http://drafts.csswg.org/css-syntax/>,
66
and need an implementation of it for testing purposes.
77

88
This parser is *not* designed to be fast,
@@ -18,7 +18,7 @@ to make the same change in the parser.
1818
It is intended to fully and completely match browser behavior
1919
(at least, as much as the final spec does).
2020

21-
There's a [dingus](https://rawgit.com/tabatkins/parse-css/master/example.html) for testing it out,
21+
There's a [dingus](https://tabatkins.github.io/parse-css/example.html) for testing it out,
2222
or just quickly checking what some CSS parses into.
2323

2424
Using the Library
@@ -43,13 +43,7 @@ and thus this parser,
4343
is *extremely generic*.
4444
It doesn't have any specific knowledge of CSS rules,
4545
just the core syntax,
46-
so it won't throw out invalid or unknown things,
47-
and it can't even actually parse the contents of blocks
48-
(because it doesn't know if they'll contain rules or declarations,
49-
and those are ambiguous without any context).
50-
I plan to add some functions that add more CSS knowledge
51-
(in an extensible way, so it'll retain anything custom that you want to handle yourself),
52-
but for now you have to do all the verification and additional parsing yourself.
46+
so it won't throw out invalid or unknown things.
5347

5448
Parsing Functions
5549
-----------------

parse-css.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,25 @@ function hexdigit(code) { return digit(code) || between(code, 0x41,0x46) || betw
1717
function uppercaseletter(code) { return between(code, 0x41,0x5a); }
1818
function lowercaseletter(code) { return between(code, 0x61,0x7a); }
1919
function letter(code) { return uppercaseletter(code) || lowercaseletter(code); }
20-
function nonascii(code) { return code >= 0x80; }
20+
function nonascii(code) {
21+
return (
22+
code == 0xb7 ||
23+
between(code, 0xc0, 0xd6) ||
24+
between(code, 0xd8, 0xf6) ||
25+
between(code, 0xf8, 0x37d) ||
26+
between(code, 0x37f, 0x1fff) ||
27+
code == 0x200c ||
28+
code == 0x200d ||
29+
code == 0x203f ||
30+
code == 0x2040 ||
31+
between(code, 0x2070, 0x218f) ||
32+
between(code, 0x2c00, 0x2fef) ||
33+
between(code, 0x3001, 0xd7ff) ||
34+
between(code, 0xf900, 0xfdcf) ||
35+
between(code, 0xfdf0, 0xfffd) ||
36+
code >= 0x10000
37+
);
38+
}
2139
function namestartchar(code) { return letter(code) || nonascii(code) || code == 0x5f; }
2240
function namechar(code) { return namestartchar(code) || digit(code) || code == 0x2d; }
2341
function nonprintable(code) { return between(code, 0,8) || code == 0xb || between(code, 0xe,0x1f) || code == 0x7f; }
@@ -1373,6 +1391,5 @@ exports.parseADeclaration = parseADeclaration;
13731391
exports.parseAComponentValue = parseAComponentValue;
13741392
exports.parseAListOfComponentValues = parseAListOfComponentValues;
13751393
exports.parseACommaSeparatedListOfComponentValues = parseACommaSeparatedListOfComponentValues;
1376-
exports.tokenize = tokenize;
13771394

13781395
}));

0 commit comments

Comments
 (0)