npm.io
0.0.10 • Published 2d ago

@m2d/list

Licence
MIT
Version
0.0.10
Deps
0
Vulns
0
Weekly
0
Stars
1

@m2d/list

CI codecov npm version npm downloads npm bundle size license

@m2d/list: Markdown List & Numbering conversion plugin for @m2d/core. Transforms ordered and bullet lists into native Word OpenXML numbering schemes.


Features

  • Hierarchical Decimal Numbering: Generates clear, multi-level outline numbering (1., 1.1., 1.1.1., A., a., i.) that avoids resetting arbitrarily at sub-levels.
  • Multi-Tier Bullet Glyphs: Automatically assigns distinct bullet characters (●, ○, ■, ◆, ▶, etc.) across nested list levels.
  • Native Word OpenXML Numbering: Registers genuine Word abstract numbering schemes in numbering.xml, ensuring list items update dynamically in Word.
  • Fully Customizable Levels: Use the exported createLevels utility to define custom indentation steps, start depths, and format sequences.
  • Word Preset Support: Toggle defaultBullets: true to seamlessly match standard Word template bullet configurations.

Installation

$ pnpm add @m2d/list @m2d/core docx

or

$ npm install @m2d/list @m2d/core docx

or

$ yarn add @m2d/list @m2d/core docx

Quick Start

import { toDocx } from "@m2d/core";
import { listPlugin } from "@m2d/list";
import remarkParse from "remark-parse";
import { unified } from "unified";

const markdown = `
# Project Plan

1. Inception Phase
   1. Requirements Gathering
   2. Stakeholder Review
2. Implementation Phase
   1. Core Engine Development
      - Microservices architecture
      - Message queues
   2. Quality Assurance
`;

const mdast = unified().use(remarkParse).parse(markdown);

const docxBlob = await toDocx(mdast, {}, {
  plugins: [listPlugin()],
});

Plugin Options

import { ILevelsOptions } from "docx";

export interface IListPluginOptions {
  /** Defines custom numbering styles for ordered lists */
  levels?: ILevelsOptions[];

  /** Defines custom numbering styles for bullet lists */
  bulletLevels?: ILevelsOptions[];

  /** Bullet characters used for unordered lists (default: ["●", "○", "■", "◆", ...]) */
  bullets?: string[];

  /** If true, uses Word's default bullet styles instead of custom ones (default: false) */
  defaultBullets?: boolean;
}

Deep Dive Guides


License

This library is licensed under the MIT open-source license.


with by Mayank Kumar Chaudhari

Keywords