mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
5d868d14ad
refs https://github.com/TryGhost/Ghost-Admin/pull/690, closes #1501, closes #2093, closes #4592, closes #4627, closes #4659, closes #5039, closes #5237, closes #5587, closes #5625, closes #5632, closes #5822, closes #5939, closes #6840, closes #7183, closes #7536 - replace custom showdown fork with markdown-it - swaps showdown for markdown-it when rendering markdown - match existing header ID behaviour - allow headers without a space after the #s - add duplicate header ID handling - remove legacy markdown spec - move markdown-it setup into markdown-converter util - update mobiledoc specs to match markdown-it newline behaviour - update data-generator HTML to match markdown-it newline behaviour - fix Post "converts html to plaintext" test - update rss spec to match markdown-it newline behaviour - close almost all related showdown bugs
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);
|
|
}
|
|
};
|