# Showdown HTML Escape plugin
[![npm version](https://badge.fury.io/js/showdown-htmlescape.svg)](http://badge.fury.io/js/showdown-htmlescape) 
[![Bower version](https://badge.fury.io/bo/showdown-htmlescape.svg)](http://badge.fury.io/bo/showdown-htmlescape)
[![Dependency Status](https://david-dm.org/phw/showdown-htmlescape.svg)](https://david-dm.org/phw/showdown-htmlescape)
[![devDependency Status](https://david-dm.org/phw/showdown-htmlescape/dev-status.svg)](https://david-dm.org/phw/showdown-htmlescape#info=devDependencies)

[![Build Status](https://travis-ci.org/phw/showdown-htmlescape.svg?branch=master)](https://travis-ci.org/phw/showdown-htmlescape)
[![Code Climate](https://codeclimate.com/github/phw/showdown-htmlescape/badges/gpa.svg)](https://codeclimate.com/github/phw/showdown-htmlescape)
[![Test Coverage](https://codeclimate.com/github/phw/showdown-htmlescape/badges/coverage.svg)](https://codeclimate.com/github/phw/showdown-htmlescape/coverage)

This plugin for [Showdown](https://github.com/showdownjs/showdown) prevents
the use of arbitrary HTML and allows only the specific Markdown syntax.

This is useful if you want to allow your users to format text using the Markdown
syntax but you do not want them to directly enter HTML.

## Installation

### With [bower](http://bower.io/)

    bower install showdown-htmlescape

### With [npm](http://npmjs.org)

    npm install showdown-htmlescape

### Manual

You can also [download the latest release zip or tarball](https://github.com/phw/showdown-htmlescape/releases) and include the file `dist/showdown-htmlescape.js` directly in your project.

## Enabling the extension

### Browser

You have to include both Showdown and the Showdown HTML Escape extension in your
project:

```HTML
<script src="showdown.min.js"></script>
<script src="showdown-htmlescape.min.js"></script>
```

After including the extension in your application, you just need to enable it
for your Showdown converter:

```JavaScript
var converter = new showdown.Converter({extensions: ['htmlescape']});
```

### Node.js

```JavaScript
var showdown = require('showdown'),
  showdownHtmlEscape = require('showdown-htmlescape');
var converter = new showdown.Converter({ extensions: [showdownHtmlEscape] });
```

## Usage example

```JavaScript
var converter = new showdown.Converter({extensions: ['htmlescape']}),
    input = 'Allows **Markdown markup**, but does not allow <b>HTML markup</b>',
    html = converter.makeHtml(input);
    console.log(html);
```

This should output:

```HTML
<p>Allows <strong>Markdown markup</strong>, but does not allow &lt;b&gt;HTML markup&lt;/b&gt;</p>
```

## Notes on security
This plugin is **not** meant to protect you from XSS attacks, it justs limits
the syntax available to the user to the Markdown specific syntax. If security
and XSS prevention is important for your use case  you still must filter the
HTML generated by Showdown.
See [Markdown's XSS Vulnerability (and how to mitigate it)](https://github.com/showdownjs/showdown/wiki/Markdown's-XSS-Vulnerability-%28and-how-to-mitigate-it%29)
for details.

## License
Showdown HTML Escape Copyright &copy; 2015-2016 Philipp Wolfer <phil@parolu.de>

Published under the MIT license, see LICENSE.txt for details.
