Skip to content

Commit 970f8ce

Browse files
committed
Replace ant with an npm-based build process
Re-organize the files to match standard node/npm conventions, and use the `browserify` package to create bundles which are completely backward-compatible with the bundles built with the previous process. Fixes: #191
1 parent af9ed3f commit 970f8ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+17461
-27565
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#Ignore timestamped build outputs.
2-
build/
3-
41
# Windows image file caches
52
Thumbs.db
63

@@ -11,4 +8,5 @@ Desktop.ini
118
.DS_Store
129

1310
# NPM files
14-
npm-debug.log
11+
npm-debug.log
12+
node_modules

.jshintrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
"evil": true,
66
"forin": true,
77
"freeze": true,
8-
"latedef": true,
8+
"latedef": "nofunc",
99
"loopfunc": true,
1010
"noarg": true,
11+
"node": true,
1112
"nonew": true,
13+
"predef": ["-SyntaxError"],
1214
"proto": true,
13-
"rhino": false,
14-
"strict": "implied",
15+
"strict": true,
1516
"undef": true,
1617
"unused": "vars"
1718
}

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ sudo: false
33
language: node_js
44

55
node_js:
6-
- "0.6"
7-
- "0.8"
86
- "0.10"
97
- "4"
108
- "5"
119

12-
script:
13-
- ant test
14-
1510
matrix:
1611
fast_finish: true

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,39 @@
55
## Introduction
66

77
The ParserLib CSS parser is a CSS3 SAX-inspired parser written in JavaScript.
8-
By default, the parser only deals with standard CSS syntax and doesn't do validation (checking of property names and values).
8+
It handles standard CSS syntax as well as validation (checking of
9+
property names and values) although it is not guaranteed to thoroughly
10+
validate all possible CSS properties.
911

1012
## Adding to your project
1113

12-
The CSS parser is intended for use primarily in command line JavaScript environments.
13-
The files you should use are in the `build` directory. Copy the files to an appropriate location for your usage.
14+
The CSS parser is built for a number of different JavaScript
15+
environments. The most recently released version of the parser
16+
can be found in the `dist` directory when you check out the
17+
repository; run `npm run build` to regenerate them from the
18+
latest sources.
1419

1520
### Node.js
1621

17-
To use the CSS parser in a Node.js script, include it at the beginning:
22+
You can use the CSS parser in a `Node.js` script via the standard
23+
`npm` package manager as the `parserlib` package (`npm install parserlib`):
24+
25+
```js
26+
var parserlib = require("parserlib");
27+
28+
var parser = new parserlib.css.Parser();
29+
```
30+
31+
Alternatively, you can copy a single file version of the parser from
32+
`dist/node-parserlib.js` to your own project, and use it as follows:
1833
```js
1934
var parserlib = require("./node-parserlib");
2035
```
2136

2237
### Rhino
2338

24-
To use the CSS parser in a Rhino script, include it at the beginning:
39+
To use the CSS parser in a Rhino script, copy the file
40+
`dist/parserlib.js` to your project and then include it at the beginning:
2541
```js
2642
load("parserlib.js");
2743
```
@@ -37,7 +53,9 @@ Or include it as its component parts, the ParserLib core and the CSS parser:
3753
<script src="parserlib-core.js"></script>
3854
<script src="parserlib-css.js"></script>
3955
```
40-
Note that parsing large JavaScript files may cause the browser to become unresponsive.
56+
Note that parsing large JavaScript files may cause the browser to
57+
become unresponsive. All three of these files are located in the
58+
`dist` directory.
4159

4260
## Basic usage
4361

@@ -360,11 +378,12 @@ parser.addListener("endrule", function(event) {
360378

361379
The `property` event fires whenever a CSS property (`name:value`) is encountered,
362380
which may be inside of a rule, a media block, a page block, etc. The `event` object
363-
has three additional properties: `property`, which is the name of the property as a
381+
has four additional properties: `property`, which is the name of the property as a
364382
`parserlib.css.PropertyName` object, `value`, which is an instance of
365383
`parserlib.css.PropertyValue` (both types inherit from `parserlib.util.SyntaxUnit`),
366-
and `important`, which is a Boolean value indicating if the property is flagged
367-
with `!important`. Example:
384+
`important`, which is a Boolean value indicating if the property is flagged
385+
with `!important`, and `invalid` which is a Boolean value indicating
386+
whether the property value failed validation. Example:
368387

369388
```js
370389
parser.addListener("property", function(event) {
@@ -417,4 +436,5 @@ a:hover, foo ... bar {
417436

418437
## Running Tests
419438

420-
With the Apache Ant build tool installed, you can run the tests via `ant test` from the repository's root.
439+
You can run the tests via `npm test` from the repository's root. You
440+
may need to run `npm install` first to install the necessary dependencies.

build.xml

Lines changed: 0 additions & 244 deletions
This file was deleted.

demos/css/CSSParserDemo.htm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<html>
33
<head>
44
<title>CSS Parser Demo</title>
5-
<script type="text/javascript" src="../../build/parserlib.js"></script>
5+
<!--<script type="text/javascript" src="../../dist/parserlib.js"></script>-->
6+
<script type="text/javascript" src="../../dist/parserlib-core.js"></script>
7+
<script type="text/javascript" src="../../dist/parserlib-css.js"></script>
68
<style type="text/css">
79
.error { color: red; }
810
</style>

demos/css/CSSTokenizerDemo.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title>CSS TokenStream Demo</title>
5-
<script type="text/javascript" src="../../build/parserlib.js"></script>
5+
<script type="text/javascript" src="../../dist/parserlib.js"></script>
66

77

88
</head>

0 commit comments

Comments
 (0)