/md-list-parser

simple parser for markdown list.

Primary LanguageTypeScript

md-list-parser

This is a simple parser for Markdown list.

live demo

install

npm install md-list-parser

how to use (example)

import * as LP from 'md-list-parser';
const input = `
- a
  - b
  - d
    - e
- f
`;

const result = LP.parse(input);

to get

const result = [
    {
        title: 'a',
        children: [
            {
                title: 'b',
            },
            {
                title: 'd',
                children: [
                    {
                        title: 'e',
                    },
                ],
            },
        ],
    },
    {
        title: 'f',
    },
]