New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

markdown-it-enhancer

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-enhancer

Markdown-it - modern pluggable markdown parser.

latest
Source
npmnpm
Version
15.1.0
Version published
Maintainers
1
Created
Source

markdown-it-enhancer

NPM version Coverage Status

This is a fork from markdown-it, there are some changes in this fork:

  • ESM only.
  • Source code migrate to TypeScript, now you don't need to install @types/markdown-it.
  • Using vite to bundle, vitest to test.
  • Async support. include parser rule, render rule, plugins, highlight function.

Version

In order to sync the update of upstream, the patch version of this fork would start with 100.

Example:

  • markdown-it@14.1.0 -> markdown-it-enhancer@14.1.1000
  • markdown-it@14.1.1 -> markdown-it-enhancer@14.1.1001

When There are some fix in this fork. It will:

  • markdown-it-enhancer@14.1.1000 -> markdown-it-enhancer@14.1.1010
  • markdown-it-enhancer@14.1.1010 -> markdown-it-enhancer@14.1.1020

Install

npm install markdown-it-enchacer
# yarn add markdown-it-enchacer
# pnpm add markdown-it-enchacer

Async Parser Rule

import { MarkdownIt } from "markdown-it-enchancer";

// delay s seconds.
const delay = (s) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, s * 1000);
  });
};

const md = new MarkdownIt();

// push a async ruler
md.block.ruler.push(
  "async_rule",
  async (_state, _startLine, _endLine, _slient) => {
    // async operation
    await delay(3);
  },
);

Async render rule

import { MarkdownIt } from "markdown-it-enchancer";

// delay s seconds.
const delay = (s) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, s * 1000);
  });
};

const md = new MarkdownIt();

// set a async render rule.
md.renderer.rules.test = async (tokens, idx, options, env, renderer) => {
  // some async operation
  await delay(3);
  return "test";
};

Async plugin

import { MarkdownIt } from "markdown-it-enchancer";

// delay s seconds.
const delay = (s) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, s * 1000);
  });
};

const md = new MarkdownIt();

md
  .use(async (md, arg1, arg2) => {
  // some async operation
    await delay(3);
  }, 'arg1', 'arg2')
  .use(async (md, arg1, arg2) => {
  // some async operation
    await delay(3);
  }, 'arg1', 'arg2')
  .use(async (md, arg1, arg2) => {
  // some async operation
    await delay(3);
  }, 'arg1', 'arg2');

// you must exec `await md.isReady()` to ensure the initializations of all plugins are success.
await md.isReady();

Async highlight function

import { MarkdownIt } from "markdown-it-enchancer";

// delay s seconds.
const delay = (s) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, s * 1000);
  });
};

const md = new MarkdownIt({
  async highlight() {
    // async operation
    await delay(3);
    return "highlight function";
  }
});

Others

maxAutoCompletedCells

Env support maxAutoCompletedCells property. See #1000

import { MarkdownIt } from "markdown-it-enchancer";

const md = new MarkdownIt();

md.render('md content', {
  maxAutoCompletedCells: 100
});

Plugins

There are some plugins that migrate to markdown-it-enhancer.

Test Toolkit

Keywords

markdown

FAQs

Package last updated on 08 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts