Skip to content

Commit 664bb72

Browse files
committed
Merge pull request #47 from Kreozot/parser-override
Parser override
2 parents 0229290 + e787d16 commit 664bb72

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.mdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ Also you can use Handlebars template in your markdown files:
212212
Current version: {{ ctx.version }}
213213
```
214214

215+
#### Parser override
216+
217+
If you want to use another markdown parser you can override the parsing function:
218+
219+
```javascript
220+
parsingFunction: function(markdownText): {
221+
return myParser.markdownToHtml(markdownText);
222+
}
223+
```
224+
215225
## Examples
216226

217227
For a live example check: [MOUT documentation](http://moutjs.com/docs/latest/)

src/js/parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ var showdown = require('showdown');
44
var Parser = function(config) {
55
this.config = config;
66
this.headingLevel = config.headingLevel || 2;
7-
var converter = new showdown.Converter();
8-
this.parseMdown = converter.makeHtml;
7+
if (config.parsingFunction) {
8+
this.parseMdown = config.parsingFunction;
9+
} else {
10+
var converter = new showdown.Converter();
11+
this.parseMdown = converter.makeHtml;
12+
}
913
}
1014

1115
Parser.prototype.parseDoc = function(mdown){

0 commit comments

Comments
 (0)