markdown-it-regex
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

markdown-it-regex

Plugin for markdown-it, replaces strings that match a regular expression pattern.

Installation

yarn add markdown-it-regex

Usage

import markdownIt from "markdown-it";
import markdownItRegex from "markdown-it-regex";
const mdi = markdownIt();
mdi.use(markdownItRegex, {
  name: "emoji",
  regex: /(:(?:heart|panda_face|car):)/,
  replace: (match) => {
    return `<i class="e1a-${match.slice(1, -1)}"></i>`;
  },
});
mdi.render("I :heart: you"); // <p>I <i class="e1a-heart"></i> you</p>

Readme

Keywords

none

Package Sidebar

Install

npm i markdown-it-regex

Weekly Downloads

2,510

Version

0.2.2

License

MIT

Unpacked Size

5.75 kB

Total Files

6

Last publish

Collaborators

  • tylerlong