Skip to content

Commit e89875f

Browse files
committed
Merge pull request #175 from CSSLint/readme
Update README.md.
2 parents 5ef3cba + c45bbd9 commit e89875f

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
CSS Parser
2-
==========
1+
# CSS Parser
32

43
[![build status](https://secure.travis-ci.org/CSSLint/parser-lib.svg)](http://travis-ci.org/CSSLint/parser-lib)
54

6-
Introduction
7-
------------
5+
## Introduction
86

97
The ParserLib CSS parser is a CSS3 SAX-inspired parser written in JavaScript. By default, the parser only deals with standard CSS syntax and doesn't do validation (checking of property names and values).
108

11-
Adding to your project
12-
----------------------
9+
## Adding to your project
1310

1411
The CSS parser is intended for use primarily in command line JavaScript environments. The files you should use are in the `build` directory. Copy the files to an appropriate location for your usage.
1512

@@ -40,8 +37,7 @@ Or include it as its component parts, the ParserLib core and the CSS parser:
4037
```
4138
Note that parsing large JavaScript files may cause the browser to become unresponsive.
4239

43-
Basic usage
44-
-----------
40+
## Basic usage
4541

4642
You can create a new instance of the parser by using the following code:
4743
```js
@@ -66,8 +62,7 @@ The `parse()` method throws an error if a non-recoverable syntax error occurs, o
6662

6763
Note: The `parseStyleSheet()` method is provided for compatibility with SAC-based APIs but does the exact same thing as `parse()`.
6864

69-
Understanding syntax units
70-
--------------------------
65+
## Understanding syntax units
7166

7267
The CSS parser defines several types that inherit from `parserlib.util.SyntaxUnit`. These types are designed to give you easy access to all relevant parts of the CSS syntax.
7368

@@ -131,16 +126,15 @@ Each instance of `parserlib.css.SelectorPart` has an `elementName` property, whi
131126
Each instance of `parserlib.css.Combinator` has an additional `type` property that indicates the type of combinator: "descendant", "child", "sibling", or "adjacent-sibling".
132127

133128

134-
Using events
135-
------------
129+
## Using events
136130

137131
The CSS parser fires events as it parses text. The events correspond to important parts of the parsing algorithm and are designed to provide developers with all of the information necessary to create lint checkers, ASTs, and other data structures.
138132

139133
For many events, the `event` object contains additional information. This additional information is most frequently in the form of a `parserlib.util.SyntaxUnit` object, which has three properties:
140134

141135
1. `text` - the string value
142-
1. `line` - the line on which this token appeared
143-
1. `col` - the column within the line at which this token appeared
136+
2. `line` - the line on which this token appeared
137+
3. `col` - the column within the line at which this token appeared
144138

145139
The `toString()` method for these objects is overridden to be the same value as `text`, so that you can treat the object as a string for comparison and concatenation purposes.
146140

@@ -293,8 +287,8 @@ parser.addListener("error", function(event){
293287
console.log("Parse error: " + event.message + " (" + event.line + "," + event.col + ")", "error");
294288
});
295289
```
296-
Error recovery
297-
--------------
290+
291+
## Error recovery
298292

299293
The CSS parser's goal is to be on-par with error recovery of CSS parsers in browsers. To that end, the following error recovery mechanisms are in place:
300294

@@ -318,7 +312,6 @@ a:hover, foo ... bar {
318312

319313
* **Unknown @ Rules** - any @ rules that isn't recognized is automatically skipped, meaning the entire block after it is not parsed.
320314

321-
Running Tests
322-
-------------
315+
## Running Tests
323316

324317
With the Apache Ant build tool installed, you can run the tests via `ant test` from the repository's root.

0 commit comments

Comments
 (0)