forked from apidoc/apidoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add info for custom markdown parser.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Markdown Parser | ||
|
||
By default apiDoc uses [markdown-it](https://github.com/markdown-it/markdown-it) Markdown Parser. | ||
|
||
|
||
|
||
## Custom Parser | ||
|
||
`apidoc --markdown /path/to/a/custom_markdown_parser.js` | ||
|
||
Your custom parser must return a class with a render-method. | ||
|
||
|
||
|
||
## Examples | ||
|
||
### With "markdown-it" Markdown Parser. | ||
|
||
```js | ||
var Markdown = require('markdown-it'); | ||
|
||
function CustomMarkdownParser() { | ||
this.markdownParser = new Markdown({ | ||
breaks : false, | ||
html : true, | ||
linkify : true, | ||
typographer: false | ||
}); | ||
} | ||
|
||
module.exports = CustomMarkdownParser; | ||
|
||
CustomMarkdownParser.prototype.render = function(text) { | ||
return this.markdownParser.render(text); | ||
}; | ||
``` | ||
|
||
|
||
|
||
### With "marked" Markdown Parser. | ||
|
||
**marked seemed to be outdated and has currently a security issue, please use it not anymore in production.** | ||
This is only an demo. | ||
|
||
```js | ||
var markdownParser = require('marked'); | ||
|
||
function CustomMarkdownParser() { | ||
markdownParser.setOptions({ | ||
gfm : true, | ||
tables : true, | ||
breaks : false, | ||
pedantic : false, | ||
sanitize : false, | ||
smartLists : false, | ||
smartypants: false | ||
}); | ||
} | ||
|
||
module.exports = CustomMarkdownParser; | ||
|
||
CustomMarkdownParser.prototype.render = function(text) { | ||
return markdownParser(text); | ||
}; | ||
``` |