Last active
November 16, 2020 17:22
-
-
Save MatthewCallis/91e8736fca2568cef07dea72ceb3708f to your computer and use it in GitHub Desktop.
Generate Markdown HTML Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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