marked-async
v0.3.7
Published
A markdown parser built for speed with async
Downloads
690
Readme
marked-async
Modified marked module for using with asynchronous renderer methods.
Install
npm install marked-async --save
marked()
function return Promise
object.
import marked from 'marked-async'
const html = await marked('I am using __markdown__.')
console.log(html)
// Outputs: <p>I am using <strong>markdown</strong>.</p>
async renderer
Default marked renderer is
import marked from 'marked-async'
const renderer = new marked.Renderer()
renderer.image = (href, title, text) => {
return `<img src="${href}" />`
}
const html = async marked('# heading+', { renderer: renderer })
console.log(html)
You can also set renderer method with async mode.
renderer.image = async (href, title, text) => {
// some async process...
const image = await fetchImage(href)
const size = await fetchImageSize(image)
return `<img src="${href}" width="${size.width}" height="${size.height}" />`
}
const html = async marked('# heading+', { renderer: renderer })
console.log(html)
Author
Yusuke Shibata
Original marked is by Christopher Jeffrey.
License
MIT