Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix README.md to make headings work in Markdown #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#NodeHtmlParser
# NodeHtmlParser
A forgiving HTML/XML/RSS parser written in JS for both the browser and NodeJS (yes, despite the name it works just fine in any modern browser). The parser can handle streams (chunked data) and supports custom handlers for writing custom DOMs/output.

##Installing
## Installing

npm install htmlparser

##Running Tests
## Running Tests

###Run tests under node:
### Run tests under node:
node runtests.js

###Run tests in browser:
### Run tests in browser:
View runtests.html in any browser

##Usage In Node
## Usage In Node

```javascript
var htmlparser = require("htmlparser");
Expand All @@ -29,7 +29,7 @@ parser.parseComplete(rawHtml);
sys.puts(sys.inspect(handler.dom, false, null));
```

##Usage In Browser
## Usage In Browser

```javascript
var handler = new Tautologistics.NodeHtmlParser.DefaultHandler(function (error, dom) {
Expand All @@ -43,7 +43,7 @@ parser.parseComplete(document.body.innerHTML);
alert(JSON.stringify(handler.dom, null, 2));
```

##Example output
## Example output

```javascript
[ { raw: 'Xyz ', data: 'Xyz ', type: 'text' }
Expand All @@ -66,7 +66,7 @@ alert(JSON.stringify(handler.dom, null, 2));
]
```

##Streaming To Parser
## Streaming To Parser

```javascript
while (...) {
Expand All @@ -76,23 +76,23 @@ while (...) {
parser.done();
```

##Streaming To Parser in Node
## Streaming To Parser in Node

```javascript
fs.createReadStream('./path_to_file.html').pipe(parser);
```

##Parsing RSS/Atom Feeds
## Parsing RSS/Atom Feeds

```javascript
new htmlparser.RssHandler(function (error, dom) {
...
});
```

##DefaultHandler Options
## Default Handler Options

###Usage
### Usage

```javascript
var handler = new htmlparser.DefaultHandler(
Expand All @@ -101,10 +101,10 @@ var handler = new htmlparser.DefaultHandler(
);
```

###Option: ignoreWhitespace
### Option: ignoreWhitespace
Indicates whether the DOM should exclude text nodes that consists solely of whitespace. The default value is "false".

####Example: true
#### Example: true

The following HTML:

Expand Down Expand Up @@ -133,7 +133,7 @@ becomes:
]
```

####Example: false
#### Example: false

The following HTML:

Expand Down Expand Up @@ -163,10 +163,10 @@ becomes:
]
```

###Option: verbose
### Option: verbose
Indicates whether to include extra information on each node in the DOM. This information consists of the "raw" attribute (original, unparsed text found between "<" and ">") and the "data" attribute on "tag", "script", and "comment" nodes. The default value is "true".

####Example: true
#### Example: true
The following HTML:

```html
Expand All @@ -186,7 +186,7 @@ becomes:
]
```

####Example: false
#### Example: false
The following HTML:

```javascript
Expand All @@ -204,10 +204,10 @@ becomes:
]
```

###Option: enforceEmptyTags
### Option: enforceEmptyTags
Indicates whether the DOM should prevent children on tags marked as empty in the HTML spec. Typically this should be set to "true" HTML parsing and "false" for XML parsing. The default value is "true".

####Example: true
#### Example: true
The following HTML:

```html
Expand All @@ -222,7 +222,7 @@ becomes:
]
```

####Example: false
#### Example: false
The following HTML:

```html
Expand All @@ -241,11 +241,11 @@ becomes:
]
```

##DomUtils
## DomUtils

###TBD (see utils_example.js for now)
### TBD (see utils_example.js for now)

##Related Projects
## Related Projects

Looking for CSS selectors to search the DOM? Try Node-SoupSelect, a port of SoupSelect to NodeJS: http://github.com/harryf/node-soupselect

Expand Down