mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
27 lines
813 B
JavaScript
27 lines
813 B
JavaScript
|
var MarkdownIt = require('markdown-it'),
|
||
|
converter = new MarkdownIt({
|
||
|
html: true,
|
||
|
breaks: true,
|
||
|
linkify: true
|
||
|
})
|
||
|
.use(require('markdown-it-footnote'))
|
||
|
.use(require('markdown-it-lazy-headers'))
|
||
|
.use(require('markdown-it-mark'))
|
||
|
.use(require('markdown-it-named-headers'), {
|
||
|
// match legacy Showdown IDs otherwise default is github style dasherized
|
||
|
slugify: function (inputString, usedHeaders) {
|
||
|
var slug = inputString.replace(/[^\w]/g, '').toLowerCase();
|
||
|
if (usedHeaders[slug]) {
|
||
|
usedHeaders[slug] += 1;
|
||
|
slug += usedHeaders[slug];
|
||
|
}
|
||
|
return slug;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
module.exports = {
|
||
|
render: function (markdown) {
|
||
|
return converter.render(markdown);
|
||
|
}
|
||
|
};
|