Home

Awesome

Showdown

Build Status: Linux Build Status: Windows Browserstack Tests npm version Bower version Donate


Showdown is a JavaScript Markdown to HTML converter, based on the original works by John Gruber. Showdown can be used client side (in the browser) or server side (with Node.js).

Live DEMO

Check out a live demo here: http://demo.showdownjs.com/

As you know, ShowdownJS is a free library and it will remain free forever. However, maintaining and improving the library costs time and money.

If you like our work and find our library useful, please donate through PayPal! Your contribution will be greatly appreciated and help me continue to develop this awesome library.

License

ShowdownJS v 2.0 is released under the MIT license. Previous versions are released under BSD.

Who uses Showdown (or a fork)

Installation

Download tarball

You can download the latest release tarball directly from releases.

Bower

bower install showdown

npm (server-side)

npm install showdown

NuGet package

PM> Install-Package showdownjs

The NuGet Packages can be found here.

CDN

You can also use one of several CDNs available:

Note: replace <version tag> with an actual full length version you're interested in e.g. 1.9.0

Browser Compatibility

Showdown has been tested successfully with:

In theory, Showdown will work in any browser that supports ECMA 262 3rd Edition (JavaScript 1.5). The converter itself might even work in things that aren't web browsers, like Acrobat. No promises.

Node compatibility

Showdown is intended to work on any supported Node.js version (see the Node.js releases schedule. The code may work with previous versions of Node.js, but no accomidations are made to ensure it does.

Legacy version

If you're looking for showdown v<1.0.0, you can find it in the legacy branch.

Changelog

You can check the full changelog

Extended documentation

Check our wiki pages for examples and a more in-depth documentation.

Quick Example

Node

var showdown  = require('showdown'),
    converter = new showdown.Converter(),
    text      = '# hello, markdown!',
    html      = converter.makeHtml(text);

Browser

var converter = new showdown.Converter(),
    text      = '# hello, markdown!',
    html      = converter.makeHtml(text);

Output

Both examples should output...

    <h1 id="hellomarkdown">hello, markdown!</h1>

Options

You can change some of showdown's default behavior through options.

Setting options

Options can be set:

Globally

Setting a "global" option affects all instances of showdown

showdown.setOption('optionKey', 'value');

Locally

Setting a "local" option only affects the specified Converter object. Local options can be set:

Getting an option

Showdown provides 2 methods (both local and global) to retrieve previous set options.

getOption()

// Global
var myOption = showdown.getOption('optionKey');

//Local
var myOption = converter.getOption('optionKey');

getOptions()

// Global
var showdownGlobalOptions = showdown.getOptions();

//Local
var thisConverterSpecificOptions = converter.getOptions();

Retrieve the default options

You can get showdown's default options with:

var defaultOptions = showdown.getDefaultOptions();

Valid Options

NOTE: Please note that until version 1.6.0, all of these options are DISABLED by default in the cli tool.

Flavors

You can also use flavors or presets to set the correct options automatically, so that showdown behaves like popular markdown flavors.

Currently, the following flavors are available:

Global

showdown.setFlavor('github');

Instance

converter.setFlavor('github');

CLI Tool

Showdown also comes bundled with a Command Line Interface tool. You can check the CLI wiki page for more info

Integration with AngularJS

ShowdownJS project also provides seamlessly integration with AngularJS via a "plugin". Please visit https://github.com/showdownjs/ngShowdown for more information.

Integration with TypeScript

If you're using TypeScript you maybe want to use the types from DefinitelyTyped

Integration with SystemJS/JSPM

Integration with SystemJS can be obtained via the third party "system-md" plugin.

Integration with VueJS

To use ShowdownJS as a Vue component quickly, you can check vue-showdown.

XSS vulnerability

Showdown doesn't sanitize the input. This is by design since markdown relies on it to allow certain features to be correctly parsed into HTML. This, however, means XSS injection is quite possible.

Please refer to the wiki article Markdown's XSS Vulnerability (and how to mitigate it) for more information.

Extensions

Showdown allows additional functionality to be loaded via extensions. (you can find a list of known showdown extensions here) You can also find a boilerplate, to create your own extensions in this repository

Client-side Extension Usage

<script src="showdown.js" />
<script src="twitter-extension.js" />

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

Server-side Extension Usage

var showdown    = require('showdown'),
    myExtension = require('myExtension'),
    converter = new showdown.Converter({ extensions: ['myExtension'] });

Building

Building your clone of the repository is easy.

Prerequesites: Node.js v12, npm and npx must be installed.

  1. run npm install.

  2. run npx grunt build (see Gruntfile.js). This command:

    1. Cleans the repo.
    2. Checks code quality (JSHint and ESLint).
    3. Runs tests.
    4. Creates the distributable and minified files in the dist folder.

Tests

A suite of tests is available which require Node.js. Once Node is installed, run the following command from the project root to install the dependencies:

npm install

Once installed the tests can be run from the project root using:

npm test

New test cases can easily be added. Create a markdown file (ending in .md) which contains the markdown to test. Create a .html file of the exact same name. It will automatically be tested when the tests are executed with mocha.

Contributing

If you wish to contribute please read the following quick guide.

Want a Feature?

You can request a new feature by submitting an issue. If you would like to implement a new feature feel free to issue a Pull Request.

Pull requests (PRs)

PRs are awesome. However, before you submit your pull request consider the following guidelines:

If you have time to contribute to this project, we feel obliged that you get credit for it. These rules enable us to review your PR faster and will give you appropriate credit in your GitHub profile. We thank you in advance for your contribution!

Joining the team

We're looking for members to help maintaining Showdown. Please see this issue to express interest or comment on this note.

Credits

Full credit list at https://github.com/showdownjs/showdown/blob/master/CREDITS.md

Showdown is powered by:<br/> webstorm