<commit_before># peacock [![build status](https://secure.travis-ci.org/thlorenz/peacock.png)](http://travis-ci.org/thlorenz/peacock)

JavaScript syntax highlighter that generates [pygments](http://pygments.org/) compatible html and therefore supports
[pygments styles](https://github.com/thlorenz/peacock/tree/master/styles).

![peacock](http://animal.discovery.com/birds/peacock/pictures/peacock-picture.jpg)

[Peacock](http://animal.discovery.com/birds/peacock/) *(Pavo cristasus)*

## Installation

    npm install peacock

## Try it 

### Online 

[peacock github page](http://thlorenz.github.com/peacock/)

### Included demo

`npm exlore peacock` 
`npm run demo`

## Features and limitations

- works server side via [nodejs](http://nodejs.org)
- works in the browser via AMD, if available, or as global window object
- **only highlights JavaScript** - if that is a dealbreaker look into some [alternatives](#alternatives)

## API

### ***peacock.highlight(code[, opts])***

Returns the highlighted version of the code that was passed or throws an error if it was not able to parse it.

#### opts:

```js
{   
    theme: {String}|{Object}
  , linenos: true|false 
}
```

#### theme:

- (`{Object}` or `{String}`) that is used to optionally override the theme used to highlight
- if it is `{Object}` it has to be of [this form](https://github.com/thlorenz/peacock/blob/master/themes/empty.js)
- it can also be a `{String}`, **if used server side** - either the name of a [built-in
  theme](https://github.com/thlorenz/peacock/tree/master/themes) or the full path to a theme anywhere on your computer

#### linenos:

- if true the generated html includes line numbers
- default is false

## Browser support

### AMD

Ensure to include [redeyed](https://github.com/thlorenz/redeyed) and [esprima](https://github.com/ariya/esprima) as your
dependencies

```js
define(['peacock'], function (peacock) {
 [ .. ]
});
```

### Attached to global window object

peacock will be exposed as `window.peacock` which allows calling `peacock.highlight` from anywhere.

```html
<script type="text/javascript" src="https://raw.github.com/ariya/esprima/master/esprima.js"></script>
<script type="text/javascript" src="https://raw.github.com/thlorenz/redeyed/master/redeyed.js"></script>
<script type="text/javascript" src="https://github.com/thlorenz/peacock/raw/master/peacock-browser.js"></script>
```

## Examples ([*browse*](https://github.com/thlorenz/peacock/tree/master/examples))

- [pageofself](https://github.com/thlorenz/peacock/blob/master/examples/pageofself.js) highlights itself using
  the [tango style](https://github.com/thlorenz/peacock/blob/master/styles/tango.css)
- [pageofself-hide-semicolons](https://github.com/thlorenz/peacock/blob/master/examples/pageofself-hide-semicolons.js) highlights itself using
  the [fruity style](https://github.com/thlorenz/peacock/blob/master/styles/fruity.css) and hides all semicolons
- [amd browser example](https://github.com/thlorenz/peacock/tree/master/examples/browser-amd) which uses
  [requirejs](http://requirejs.org) to resolve peacock
- [simple browser example](https://github.com/thlorenz/peacock/tree/master/examples/browser-simple) which uses the<commit_msg>updating readme to JS resource fix<commit_after># peacock [![build status](https://secure.travis-ci.org/thlorenz/peacock.png)](http://travis-ci.org/thlorenz/peacock)

JavaScript syntax highlighter that generates [pygments](http://pygments.org/) compatible html and therefore supports
[pygments styles](https://github.com/thlorenz/peacock/tree/master/styles).

![peacock](http://animal.discovery.com/birds/peacock/pictures/peacock-picture.jpg)

[Peacock](http://animal.discovery.com/birds/peacock/) *(Pavo cristasus)*

## Installation

    npm install peacock

## Try it 

### Online 

[peacock github page](http://thlorenz.github.com/peacock/)

### Included demo

`npm exlore peacock` 
`npm run demo`

## Features and limitations

- works server side via [nodejs](http://nodejs.org)
- works in the browser via AMD, if available, or as global window object
- **only highlights JavaScript** - if that is a dealbreaker look into some [alternatives](#alternatives)

## API

### ***peacock.highlight(code[, opts])***

Returns the highlighted version of the code that was passed or throws an error if it was not able to parse it.

#### opts:

```js
{   
    theme: {String}|{Object}
  , linenos: true|false 
}
```

#### theme:

- (`{Object}` or `{String}`) that is used to optionally override the theme used to highlight
- if it is `{Object}` it has to be of [this form](https://github.com/thlorenz/peacock/blob/master/themes/empty.js)
- it can also be a `{String}`, **if used server side** - either the name of a [built-in
  theme](https://github.com/thlorenz/peacock/tree/master/themes) or the full path to a theme anywhere on your computer

#### linenos:

- if true the generated html includes line numbers
- default is false

## Browser support

### AMD

Ensure to include [redeyed](https://github.com/thlorenz/redeyed) and [esprima](https://github.com/ariya/esprima) as your
dependencies

```js
define(['peacock'], function (peacock) {
 [ .. ]
});
```

### Attached to global window object

peacock will be exposed as `window.peacock` which allows calling `peacock.highlight` from anywhere.

```html
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/esprima/2.7.2/esprima.min.js"></script>
<script type="text/javascript" src="https://rawgit.com/thlorenz/redeyed/master/redeyed.js"></script>
<script type="text/javascript" src="https://rawgit.com/thlorenz/peacock/master/peacock-browser.js"></script>
```

## Examples ([*browse*](https://github.com/thlorenz/peacock/tree/master/examples))

- [pageofself](https://github.com/thlorenz/peacock/blob/master/examples/pageofself.js) highlights itself using
  the [tango style](https://github.com/thlorenz/peacock/blob/master/styles/tango.css)
- [pageofself-hide-semicolons](https://github.com/thlorenz/peacock/blob/master/examples/pageofself-hide-semicolons.js) highlights itself using
  the [fruity style](https://github.com/thlorenz/peacock/blob/master/styles/fruity.css) and hides all semicolons
- [amd browser example](https://github.com/thlorenz/peacock/tree/master/examples/browser-amd) which uses
  [requirejs](http://requirejs.org) to resolve peacock
- [simple browser example](https://github.com/thlorenz/peacock/tree/master/examples/browser-simple) which uses the
{'fraction_non_alphanumeric': 0.15432290052680508, 'fraction_numerical': 0.00046482801363495507, 'mean_word_length': 4.79443447037702, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 32, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1903831', 'n_tokens_mistral': 2246, 'n_tokens_neox': 2142, 'n_words': 498}