Simple marked renderer to include image attributes in markdown. Also generates vimeo links.
npm install marked-images
NOTE: breaking changes:
- As of v2.0.0, this library uses the
marked.use()
plugin api. - As of v3.0.0, since marked v4.x the
marked()
function is no longer the default export. CommonJS code which doesmarked = require(marked)
should be changed to callmarked.marked(<markdown-string>)
instead ofmarked()
.
var marked = require('marked');
var markedImages = require('marked-images');
// opts are optional
var opts = {
xhtml: false,
fqImages: { route: '/images/', url:'https://images.example.com' }, // use custom image endpoint url when link starts with route
fqLinks: 'https://www.example.com', // generate fully qualified links if fqImages is not set
relPath: false
}
marked.use(markedImages(opts));
var html = marked.marked(markdown);
{number}x{number} in the title text part of the link in quotes after the url e.g.

or

generates:
<img src="src" alt="" width="1" height="2" title="title text">
any attribute name=value, no quotes around the value e.g.

generates:
<img src="src" alt="" width="1" height="2" align="right" title="title text">
.{classname}

generates:
<iframe src="//player.vimeo.com/video/00000000" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen width="500" height="281"></iframe>