Most Featureful Markdown Parser
My favorite implementation is Markdown Preview Enhanced, to be exact, @shd101wyy/mume, but I want a little more features…
shd101wyy/mume
Another one that I love, is Discourse's (forum).
My favorite implementation is Markdown Preview Enhanced, to be exact, @shd101wyy/mume, but I want a little more features…
Another one that I love, is Discourse's (forum).
Let me say this first, the best way to create PDF from markdown is via web technology (Chrome / Puppeteer), because it is the closest to WSYIWYG (What You See Is What You Get), but it is not perfect.
It currently misses at least one PDF specific features (and possibly more) - Table of Contents / Bookmarks.
And one of the best tools to create PDF is Visual Studio Code, if you know how to use Markdown Preview Enhanced properly. (I've just noticed that I can use this in Atom as well.)
Indeed, the way includes
Therefore, I suggest a way of using a web driver + a PDF library, that can READ and MODIFY pdf.
The web driver is currently best either Puppeteer, or Chrome DevTools Protocol.
You can use any markdown implementation, including MarkdownIt, but first you have to make it insecure first, by allowing HTML.
const markdownIt = MarkdownIt({
html: true
})
Then, use DOMPurify, but allow <iframe>
tag, including related attributes.
Then, sanitize insecure iframes later.
DOMPurify.addHook('uponSanitizeElement', (node, data) => {
if (data.tagName === 'iframe') {
const src = node.getAttribute('src') || ''
if (!src.startsWith('https://www.youtube.com/embed/')) {
return node.parentNode?.removeChild(node)
}
}
})
Pug is a high-performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers.
Pug uses whitespace syntax, and is Tab / Space -sensitive, just like Markdown and Python
Pug is mainly a template engine for Node.js, and cannot be installed for Webpack via NPM/Yarn, however there is https://github.com/pugjs/pug#browser-support but it is a very large file. However, I created HyperPug a while ago, and it is relatively small.