Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

markdown-it-regex

tylingsoft12.6kMIT0.2.2TypeScript support: included

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

readme

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>