@tlylt/rmark
v1.0.0
Published
A simple regex-based toy Markdown parser written in TypeScript
Downloads
1
Readme
RMark
RMark is a simple regex-based toy Markdown parser written in TypeScript.
Usage
Install the package:
npm install @tlylt/rmark
Import the package and use it:
import { RMark } from '@tlylt/rmark';
const rmark = new RMark();
const html = rmark.render('# Hello, world!');
Add more rules to the parser:
import { RMark, Rule, Pattern } from '@tlylt/rmark';
const rmark = new RMark();
rmark.addRule(
new Rule('horizontal', [
new Pattern(/^(-{3})/gm, '<hr />'),
new Pattern(/^(_{3})/gm, '<hr />'),
])
);
const html = rmark.render('---');