Skip to content

Instantly share code, notes, and snippets.

@MatthewCallis
Last active November 16, 2020 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewCallis/91e8736fca2568cef07dea72ceb3708f to your computer and use it in GitHub Desktop.
Save MatthewCallis/91e8736fca2568cef07dea72ceb3708f to your computer and use it in GitHub Desktop.
Generate Markdown HTML Example
const fs = require('fs');
const MarkdownItRenderer = require('@uttori/plugin-renderer-markdown-it');
const config = {
// Uttori Specific Configuration
uttori: {
// Prefix for relative URLs, useful when the Express app is not at root.
baseUrl: '',
// Good Noodle List, f a domain is not in this list, it is set to 'external nofollow noreferrer'.
allowedExternalDomains: [
'eludevisibility.org',
'sfc.fm',
'snes.in',
'superfamicom.org',
'wiki.superfamicom.org',
],
// Open external domains in a new window.
openNewWindow: true,
// Table of Contents
toc: {
// The opening DOM tag for the TOC container.
openingTag: '<nav class="table-of-contents">',
// The closing DOM tag for the TOC container.
closingTag: '</nav>',
// Slugify options for convering content to anchor links.
slugify: {
lower: true,
},
},
},
};
try {
const data = fs.readFileSync('./test.md', 'utf8');
const output = MarkdownItRenderer.render(data, config);
fs.writeFile('./test.html', output, () => {});
} catch (err) {
console.error(err);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment