开发者社区> 镜像站> NPM> marli
marli
markdown tagged template literal renderer
Last updated 3 years ago by yerkopalma .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install marli 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

4 Versions

  • 2.0.0                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (1)
Dev Dependencies (10)
Dependents (2)