Skip to content

Latest commit

 

History

History
64 lines (51 loc) · 1.03 KB

README.md

File metadata and controls

64 lines (51 loc) · 1.03 KB

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