1.0.0 • Published 3 years ago
@tlylt/rmark v1.0.0
RMark
RMark is a simple regex-based toy Markdown parser written in TypeScript.
Usage
Install the package:
npm install @tlylt/rmarkImport 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('---');1.0.0
3 years ago