Home

Awesome

marli

Build Status js-standard-style

markdown tagged template literal render

Install

$ npm install --save marli

Usage

var Markdown = require('marli')
var md = Markdown()

var dom = md`
**Hello** _world_
---
`
document.body.appendChild(dom)

API

md = Markdown([presetName][, options])

Marli uses markdown-it under the hood, so it accepts the same arguments for it's constructor. Check markdown-it constructor docs for more info. You can also pass a rules object as an option property, that will be passed to the renderer, so you can overrider rules like this

function link_open (tokens, idx, options, env, self) { // eslint-disable-line camelcase
  var aIndex = tokens[idx].attrIndex('target')

  if (aIndex < 0) {
    tokens[idx].attrPush(['target', '_blank'])
  } else {
    tokens[idx].attrs[aIndex][1] = '_blank'
  }
  return defaultRender(tokens, idx, options, env, self)
}
var md = require('marli')({ rules: { link_open } })
var mdDom = marli`[google](www.google.com)`
// outputs
// <p><a href="www.google.com" target="_blank">google</a></p>

In the same way you can pass plugins to Markdown-it constructor, like this

var Markdown = require('./')
var md = Markdown({plugins: [require('markdown-it-meta')]})

License

MIT