Skip to content

Commit

Permalink
Added Node & JSDom example.
Browse files Browse the repository at this point in the history
  • Loading branch information
ironikart committed Aug 25, 2016
1 parent 0980501 commit 2667105
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ debugging purposes, follow the above steps, but run <code>grunt build-debug</cod

### Command-Line processing

#### PhantomJS

If you are using command-line processing, you don't need to build the auditor as above.
You will, however, need [PhantomJS](http://www.phantomjs.org/) installed if you wish to
use the contributed command-line script. PhantomJS provides a headless Webkit-based
Expand All @@ -72,6 +74,34 @@ recent (or slightly less than recent) versions of Safari.

See the <code>Contrib/PhantomJS/HTMLCS_Run.js</code> file for more information.

#### Node & JSDom.

HTML_CodeSniffer requires a dom to run, however, it is possible to run it entirely
server side without a headless browser using Node on arbitrary fragments of HTML using
an environment wrapper like [JSDom](https://github.com/tmpvar/jsdom).

An example node script:
```javascript
var jsdom = require('jsdom');
var fs = require('fs');

var vConsole = jsdom.createVirtualConsole();

// Forward messages to the console.
vConsole.on('log', function(message) {
console.log(message);
})

jsdom.env({
html: '<img src="test.png" />',
src: [fs.readFileSync('./build/HTMLCS.js')],
virtualConsole: vConsole,
done: function (err, window) {
window.HTMLCS_RUNNER.run('WCAG2AA');
}
});
```

### Contributing and reporting issues

To report any issues with using HTML_CodeSniffer, please use the
Expand Down

0 comments on commit 2667105

Please sign in to comment.