1.1.1 • Published 5 years ago

mdast-builder v1.1.1

Weekly downloads
8,008
License
BSD-2-Clause
Repository
github
Last release
5 years ago

mdast-builder

Build Status

Use composable functions to buld up a mdast structure

Use

yarn add mdast-builder
import {
  root,
  paragraph,
  text,
  heading,
  list,
  listItem,
  brk
} from 'mdast-builder';
import * as stringify from 'remark-stringify';
import * as unified from 'unified';

const processor = unified().use(stringify, {
  bullet: '-',
  fence: '`',
  fences: true,
  incrementListMarker: false
});

const output = processor.stringify(
  root([
    heading(2, text('Begin')),
    paragraph([
      paragraph(text('these are the starting instructions')),
      brk,
      brk,
      list('unordered', [
        listItem(text('one')),
        listItem(text('two')),
        listItem(text('three'))
      ])
    ])
  ])
);

output will equal

## Begin

these are the starting instructions

- one
- two
- three

Legal

© 2019 LinkedIn