You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
898 B
30 lines
898 B
const remark = require('remark');
|
|
const externalLinks = require('remark-external-links'); // Add _target and rel to external links
|
|
const customHeaders = require('./remark-header-custom-ids'); // Custom header id's for i18n
|
|
const images = require('remark-images'); // Improved image syntax
|
|
const unrwapImages = require('remark-unwrap-images'); // Removes <p> wrapper around images
|
|
const smartyPants = require('./remark-smartypants'); // Cleans up typography
|
|
const html = require('remark-html');
|
|
|
|
module.exports = {
|
|
remarkPlugins: [
|
|
externalLinks,
|
|
customHeaders,
|
|
images,
|
|
unrwapImages,
|
|
smartyPants,
|
|
],
|
|
markdownToHtml,
|
|
};
|
|
|
|
async function markdownToHtml(markdown) {
|
|
const result = await remark()
|
|
.use(externalLinks)
|
|
.use(customHeaders)
|
|
.use(images)
|
|
.use(unrwapImages)
|
|
.use(smartyPants)
|
|
.use(html)
|
|
.process(markdown);
|
|
return result.toString();
|
|
}
|
|
|