mdast-builder
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i mdast-builder

Weekly Downloads

21,750

Version

1.1.1

License

BSD-2-Clause

Unpacked Size

33.6 kB

Total Files

27

Last publish

Collaborators

  • mike-north-bot