Version 0.0.10
Overview
Updated 5 min ago
@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
createLevelsutility to define custom indentation steps, start depths, and format sequences. - 🏢 Word Preset Support: Toggle
defaultBullets: trueto seamlessly match standard Word template bullet configurations.
📦 Installation
$ pnpm add @m2d/list @m2d/core docxor
$ npm install @m2d/list @m2d/core docxor
$ 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
- 🔢 Ordered Lists & Hierarchical Numbering Guide: Multi-level decimal numbering schemas, outline sequences, and the
createLevelshelper. - 🔲 Bullet Styles & Nesting Guide: Bullet glyph hierarchies, custom characters, and Word native preset modes.
License
This library is licensed under the MIT open-source license.
with 💖 by Mayank Kumar Chaudhari