8000 first commit · ZauberNerd/css-parser@ffc5a1e · GitHub
Skip to content

Commit ffc5a1e

Browse files
author
Tab Atkins
committed
first commit
0 parents  commit ffc5a1e

File tree

4 files changed

+743
-0
lines changed

4 files changed

+743
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Standards-Based CSS Parser
2+
==========================
3+
4+
This project implements a standards-based CSS Parser.
5+
I'm writing the CSS Syntax spec <http://dev.w3.org/csswg/css3-syntax>,
6+
and need an implementation of it for testing purposes.
7+
8+
This parser is *not* designed to be fast.
9+
Its structure and coding style are instead meant to be very close to the spec,
10+
so that it's easy to verify that the code matches the spec
11+
(and vice versa)
12+
and to make it easy,
13+
when the spec changes,
14+
to make the same change in the parser.
15+
16+
However, it may still be useful to someone in production,
17+
as it is intended to fully and completely match browser behavior
18+
(at least, as much as the final spec does).

example.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!doctype html>
2+
<textarea id='css'>u+5 u+a?</textarea>
3+
<button onclick='parseStuff()'>Parse</button>
4+
<textarea id='json'></textarea>
5+
<style>
6+
html,body { height: 100%; margin: 0; padding: 0; }
7+
body {
8+
display: -webkit-flex;
9+
-webkit-align-items: center;
10+
}
11+
textarea {
12+
-webkit-flex: 1;
13+
-webkit-align-self: stretch;
14+
height: 100%;
15+
}
16+
</style>
17+
<script>
18+
var debug;
19+
function parseStuff() {
20+
var css = document.querySelector('#css').value;
21+
var tokens = tokenize(css);
22+
debug = tokens;
23+
console.log(tokens);
24+
var txt = document.querySelector('#json');
25+
txt.value = tokens.join(' ');
26+
}
27+
</script>
28+
<script src="tokenizer.js"></script>

parser.js

Whitespace-only changes.

0 commit comments

Comments
 (0)