<commit_before># Interweave v0.4.0
[![Build Status](https://travis-ci.org/milesj/interweave.svg?branch=master)](https://travis-ci.org/milesj/interweave)

Interweave is a robust library that can...

* Safely render HTML without using `dangerouslySetInnerHTML`.
* Clean HTML attributes using filters.
* Match and replace text using matchers.
* Autolink URLs, IPs, emails, and hashtags.
* Render or replace Emoji characters.
* And much more!

## Requirements

* ES2015
* React 0.14+
* IE9+

## Installation

Interweave requires React as a peer dependency.

```
npm install interweave react --save
```

## Usage

Interweave can primarily be used through the `Interweave` and `Markup`
components, both of which provide an easy, straight-forward implementation
for safely [parsing and rendering HTML](#html-parsing)
without using [dangerouslySetInnerHTML](https://facebook.github.io/react/tips/dangerously-set-inner-html.html).

The `Interweave` component has the additional benefit of utilizing
[filters](#filters), [matchers](#matchers), and callbacks.

```javascript
import Interweave from 'interweave';

<Interweave
    tagName="div"
    className="foo"
    content="This string <b>contains</b> HTML."
/>
```

#### Props

* `content` (string) - The string to render and apply matchers and
  filters to. Supports HTML.
* `tagName` (div | span | p) - The HTML element tag name to wrap the
  output with. Defaults to "span".
* `className` (string) - Class name to append to the HTML element.
* `filters` (Filter[]) - Filters to apply to this local instance.
* `matchers` (Matcher[]) - Matchers to apply to this local instance.
* `disableFilters` (boolean) - Disables both global and local filters.
* `disableMatchers` (boolean) - Disables both global and local matchers.
* `noHtml` (boolean) - Strips HTML tags from the content string while
  parsing.
* `onBeforeParse` (func) - Callback that fires before parsing. Is
  passed the source string and must return a string.
* `onAfterParse` (func) => Callback that fires after parsing. Is
  passed an array of strings/elements and must return an array.

### Markup

Unlike the `Interweave` component, the `Markup` component does not
support matchers, filters, or callbacks. This component is preferred
when rendering strings that contain HTML is the primary use case.

```javascript
import { Markup } from 'interweave';

<Markup content="This string <b>contains</b> HTML." />
```

#### Props

The `Markup` component only supports the `content`, `tagName`, and
`className` props mentioned previously.

## Documentation

* [Matchers](#matchers)
    * [Creating A Matcher](#creating-a-matcher)
    * [Rendered Components](#rendered-components)
* [Filters](#filters)
    * [Creating A Filter](#creating-a-filter)
* [Autolinking](#autolinking)
    * [URLs, IPs](#urls-ips)
    * [Emails](#emails)
    * [Hashtags](#hashtags)
* [HTML Parsing](#html-parsing)
    * [Tag Whitelist](#tag-whitelist)
    * [Attribute Whitelist](#attribute-whitelist)

### Matchers

#### Creating A Matcher

### Filters

#### Creating A Filter

### Autolinking

Autolinking is the concept of matching patterns within a string and
wrapping the matched result in an anchor link (an `<a>` tag).
This can be achieved with the [matchers](#matchers) described below.
<commit_msg>Updated readme.<commit_after># Interweave v0.5.0
[![Build Status](https://travis-ci.org/milesj/interweave.svg?branch=master)](https://travis-ci.org/milesj/interweave)

Interweave is a robust library that can...

* Safely render HTML without using `dangerouslySetInnerHTML`.
* Clean HTML attributes using filters.
* Match and replace text using matchers.
* Autolink URLs, IPs, emails, and hashtags.
* Render or replace Emoji characters.
* And much more!

## Requirements

* ES2015
* React 0.14+
* IE9+

## Installation

Interweave requires React as a peer dependency.

```
npm install interweave react --save
```

## Usage

Interweave can primarily be used through the `Interweave` and `Markup`
components, both of which provide an easy, straight-forward implementation
for safely [parsing and rendering HTML](#html-parsing)
without using [dangerouslySetInnerHTML](https://facebook.github.io/react/tips/dangerously-set-inner-html.html).

The `Interweave` component has the additional benefit of utilizing
[filters](#filters), [matchers](#matchers), and callbacks.

```javascript
import Interweave from 'interweave';

<Interweave
    tagName="div"
    className="foo"
    content="This string <b>contains</b> HTML."
/>
```

#### Props

* `content` (string) - The string to render and apply matchers and
  filters to. Supports HTML.
* `emptyContent` (node) - React node to render if no content was
  rendered.
* `tagName` (div | span | p) - The HTML element tag name to wrap the
  output with. Defaults to "span".
* `className` (string) - Class name to append to the HTML element.
* `filters` (Filter[]) - Filters to apply to this local instance.
* `matchers` (Matcher[]) - Matchers to apply to this local instance.
* `disableFilters` (boolean) - Disables both global and local filters.
* `disableMatchers` (boolean) - Disables both global and local matchers.
* `noHtml` (boolean) - Strips HTML tags from the content string while
  parsing.
* `onBeforeParse` (func) - Callback that fires before parsing. Is
  passed the source string and must return a string.
* `onAfterParse` (func) => Callback that fires after parsing. Is
  passed an array of strings/elements and must return an array.

### Markup

Unlike the `Interweave` component, the `Markup` component does not
support matchers, filters, or callbacks. This component is preferred
when rendering strings that contain HTML is the primary use case.

```javascript
import { Markup } from 'interweave';

<Markup content="This string <b>contains</b> HTML." />
```

#### Props

The `Markup` component only supports the `content`, `emptyContent`,
`tagName`, and `className` props mentioned previously.

## Documentation

* [Matchers](#matchers)
    * [Creating A Matcher](#creating-a-matcher)
    * [Rendered Components](#rendered-components)
* [Filters](#filters)
    * [Creating A Filter](#creating-a-filter)
* [Autolinking](#autolinking)
    * [URLs, IPs](#urls-ips)
    * [Emails](#emails)
    * [Hashtags](#hashtags)
* [HTML Parsing](#html-parsing)
    * [Tag Whitelist](#tag-whitelist)
    * [Attribute Whitelist](#attribute-whitelist)

### Matchers

#### Creating A Matcher

### Filters

#### Creating A Filter

### Autolinking

Autolinking is the concept of matching patterns within a string and
wrapping the matched result in an anchor link (an `<a>` tag).
This can be achieved with the [matchers](#matchers) described below.

{'fraction_non_alphanumeric': 0.12070775228669965, 'fraction_numerical': 0.003298845404108562, 'mean_word_length': 4.609756097560975, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 6, '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': '1285685', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1984, 'n_words': 719}