Sometimes you want markdown like syntax but not exact markdown specification. I build a really tiny markdown like syntax parser that you can use out of box or use the functions it exposes to write a custom markdown parser
you can install the package using npm or yarn
$ npm i pico-markdown-parser
Simple usage #
import pico from "pico-markdown-parser";
const htmlOutput = pico(`
This is a sample text!!
Building your own parser #
This parser is composed of many small parsers you can import those small parsers from the library and put them together in ways you see fit (like Lego pieces).
} from "pico-markdown-parser";
// This new parser now supports only bold and heading
const parser = (input) =>
many(choice([heading, bold, anything]))
const htmlOutput = parser(`
This is a **sample** text!!
If the small parsers it gives does not suit your need you can even write your own parser and combine it. This parser is based on arcsecond
Here is the repo. PR's are welcomed !!!
This post is also available on DEV.