UNPKG

3.03 kBMarkdownView Raw
1ember-cli-showdown
2==============================================================================
3
4[![Ember Observer Score](http://emberobserver.com/badges/ember-cli-showdown.svg)](http://emberobserver.com/addons/ember-cli-showdown)
5
6This addon provides a component that transforms [Markdown](http://en.wikipedia.org/wiki/Markdown) into valid HTML.
7
8* Fastboot compatible
9
10## Requirements
11
12* Ember.js v3.12 or above
13* Ember CLI v2.13 or above
14* Node.js v12 or above
15
16## Usage
17From within your Ember CLI application, run the following:
18
19- `ember install ember-cli-showdown`
20
21Passing a markdown string inline:
22
23```handlebars
24{{markdown-to-html "#Markdown is cool [link](http://emberjs.com)"}}
25```
26
27```html
28<!-- Output -->
29<h1>Markdown is cool <a href="http://emberjs.com">link</a></h1>
30```
31
32You can also pass a bound value:
33
34```handlebars
35{{markdown-to-html postContent}}
36```
37
38### Showdown Options
39
40You can use [configuration settings from Showdown][showdown-config]:
41
42```handlebars
43{{markdown-to-html
44 markdown=postContent
45 strikethrough=true
46 literalMidWordUnderscores=true
47 simplifiedAutoLink=true}}
48```
49
50[showdown-config]: https://github.com/showdownjs/showdown#valid-options
51
52#### Global Showdown Options
53
54Global options are supported as of 2.11.x. This lets you define options that will be used
55for showdown options that were not provided as an attribute.
56
57An example where you always want to auto link:
58
59```js
60// config/environment.js
61module.exports = function(environment) {
62 var ENV = {
63 showdown: {
64 simplifiedAutoLink: true
65 }
66 }
67
68 return ENV;
69}
70```
71
72### Showdown Extensions
73
74You can load [Showdown Extensions](https://github.com/showdownjs/showdown/wiki/extensions) by specifying the
75"extensions" property when initializing your component:
76
77```handlebars
78{{markdown-to-html
79 markdown=postContent
80 extensions=myExtensionList}}
81```
82
83```handlebars
84{{markdown-to-html
85 markdown=postContent
86 extensions='foo bar baz'}}
87```
88
89(`myExtensionList` can be an array of strings or a space separated string)
90
91Note that you'll have to register your extensions with Showdown first.
92For example, in an initializer:
93
94```js
95// app/initializers/register-showdown-extensions.js
96import showdown from 'showdown';
97
98export function initialize() {
99 showdown.extension("myExtensionName", function() {
100 return [{
101 type: 'html',
102 regex: '<blockquote>',
103 replace: '<blockquote class="blockquote">'
104 }];
105 });
106}
107
108export default {
109 name: 'register-showdown-extensions',
110 initialize
111};
112```
113
114[showdown-extensions]: https://github.com/showdownjs/showdown/wiki/extensions
115
116## 3.x to 4.3 migration
117* Global `showdown` is no longer supported. Must be imported via `import showdown from 'showdown'`
118* Remove any use of `FastBoot.require('require')` with `import showdown from 'showdown'`
119
120## Dependencies
121* [Showdown](https://github.com/showdownjs/showdown)
122
123## Contributing
124
125See the [Contributing](CONTRIBUTING.md) guide for details.
126
127## License
128
129This project is licensed under the [MIT License](LICENSE.md).