showdown/docs/extensions.md

36 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

Showdown allows you to load additional functionality via extensions. You can find a list of known Showdown extensions [here][ext-list].
2022-03-31 04:35:17 +08:00
You can also check the [boilerplate repo][boilerplate-repo], to create your own extension(s).
## Usage
=== "Server-side"
```js
// Using a bundled extension
var showdown = require('showdown');
var converter = new showdown.Converter({ extensions: ['twitter'] });
// Using a custom extension
var mine = require('./custom-extensions/mine');
var converter = new showdown.Converter({ extensions: ['twitter', mine] });
```
=== "Client-side"
```js
<script src="src/showdown.js"></script>
<script src="src/extensions/twitter.js"></script>
<script>var converter = new showdown.Converter({ extensions: ['twitter'] });</script>
```
=== "CLI"
In the CLI tool, use the [`-e` flag](/cli/#-e-extensions) to load an extension.
```sh
showdown -e twitter -i foo.md -o bar.html
```
[ext-list]: extensions-list.md
2022-03-31 04:35:17 +08:00
[boilerplate-repo]: https://github.com/showdownjs/extension-boilerplate