mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
Note that the AST now carries the name “mdast”, meaning
utilities (such as mdast-util-inject) keep their name.
This name-change includes the `mdast` formatter, which also changed
to `remark`.
Additionally:
* Update relating packages.
* Fix a bug where `text` nodes without value were
[generated](6b905aefb1/lib/output/markdown_ast.js (L144)).
24 lines
704 B
JavaScript
24 lines
704 B
JavaScript
'use strict';
|
|
|
|
var remark = require('remark'),
|
|
toc = require('remark-toc'),
|
|
markdownAST = require('./markdown_ast');
|
|
|
|
/**
|
|
* Formats documentation as
|
|
* [Markdown](http://daringfireball.net/projects/markdown/).
|
|
*
|
|
* @param {Array<Object>} comments parsed comments
|
|
* @param {Object} opts Options that can customize the output
|
|
* @param {Function} callback called with null, string
|
|
* @name markdown
|
|
* @return {undefined} calls callback
|
|
*/
|
|
module.exports = function (comments, opts, callback) {
|
|
var processor = remark().use(toc);
|
|
markdownAST(comments, opts, function (err, ast) {
|
|
var processedAST = processor.run(ast);
|
|
return callback(null, processor.stringify(processedAST));
|
|
});
|
|
};
|