0.0.4 • Published 6 years ago

chin-plugin-unified v0.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

chin-plugin-unified

npm npm Build Status Coverage Status

chin plugin using unified.

Installation

yarn add -D chin chin-plugin-unified

Usage

unified(extension, list|preset)

Just using processor.use().

import unified from 'chin-plugin-unified'
import md2mdast from 'remark-parse'
import mdast2hast from 'remark-rehype'
import hastformat from 'rehype-format'
import hast2html from 'rehype-stringify'

// as list
const md = unified('.html', [
  [md2mdast, {}],
  [mdast2hast, {}],
  [hastformat, {}],
  [hast2html, {}]
])

// as preset
const md = unified('.html', {
  settings: {},
  plugins: [
    [md2mdast, {}],
    [mdast2hast, {}],
    [hastformat, {}],
    [hast2html, {}]
  ]
})

unified(type, list|options)

Determines parser/compiler(/extension) by type.

import unified from 'chin-plugin-unified'
import mdast2hast from 'remark-rehype'
import hastformat from 'rehype-format'

// as list
const md = unified('m2h', [
  [mdast2hast, {}],
  [hastformat, {}]
])

// as options
const md = unified('m2h', {
  parse: {},
  compile: {},
  settings: {},
  plugins: [
    [mdast2hast, {}],
    [hastformat, {}]
  ]
})

type

valueparsercompilerrequired in list
"h2h"rehype-parserrehype-stringify
"h2m"rehype-parserremark-stringifyrehype-remark
"m2m"remark-parserremark-stringify
"m2h"remark-parserrehype-stringifyremark-rehype

options ( extends preset )

  • setting
  • plugins set to list
  • parse options passed to parser.
  • compile options passed to compiler.

reference

License

MIT (http://opensource.org/licenses/MIT)