UNPKG

@mdast2docx/list

Version:

Plugin to convert ordered and unordered lists from Markdown (MDAST) to DOCX. Supports nesting, custom bullets, and numbering styles.

58 lines (57 loc) 3.16 kB
import { ILevelsOptions, LevelFormat } from "docx"; import type { IPlugin, Optional } from "@m2d/core"; /** * Default options for the list plugin. */ interface IDefaultListPluginOptions { /** Defines the numbering styles for ordered lists. */ levels: ILevelsOptions[]; /** Defines the numbering styles for bullet lists (optional). */ bulletLevels?: ILevelsOptions[]; /** * Bullet characters used for unordered lists. * These closely match the default bullets in Microsoft Word. */ bullets: string[]; /** If true, uses Word's default bullet styles instead of custom ones. */ defaultBullets: boolean; } /** Type representing optional list plugin options. */ export type IListPluginOptions = Optional<IDefaultListPluginOptions>; /** * Generates a list of numbering levels for ordered lists. * * @param levelFormats - An array of level formats defining the numbering style at each level. * @param indent - The starting indentation in inches for the first level. * @param indentStep - The incremental indentation added for each subsequent level. * @returns An array of `ILevelsOptions` defining the hierarchical numbering style. * * Example: * - Level 1: "1." * - Level 2: "1.1." * - Level 3: "1.1.1." * - Level 4: "A." * - Level 5: "a." */ export declare const createLevels: (levelFormats: (typeof LevelFormat)[keyof typeof LevelFormat][], indent?: number, // Base indentation for the first level (in inches) indentStep?: number) => { level: number; format: "decimal" | "upperRoman" | "lowerRoman" | "upperLetter" | "lowerLetter" | "ordinal" | "cardinalText" | "ordinalText" | "hex" | "chicago" | "ideographDigital" | "japaneseCounting" | "aiueo" | "iroha" | "decimalFullWidth" | "decimalHalfWidth" | "japaneseLegal" | "japaneseDigitalTenThousand" | "decimalEnclosedCircle" | "decimalFullWidth2" | "aiueoFullWidth" | "irohaFullWidth" | "decimalZero" | "bullet" | "ganada" | "chosung" | "decimalEnclosedFullstop" | "decimalEnclosedParen" | "decimalEnclosedCircleChinese" | "ideographEnclosedCircle" | "ideographTraditional" | "ideographZodiac" | "ideographZodiacTraditional" | "taiwaneseCounting" | "ideographLegalTraditional" | "taiwaneseCountingThousand" | "taiwaneseDigital" | "chineseCounting" | "chineseLegalSimplified" | "chineseCountingThousand" | "koreanDigital" | "koreanCounting" | "koreanLegal" | "koreanDigital2" | "vietnameseCounting" | "russianLower" | "russianUpper" | "none" | "numberInDash" | "hebrew1" | "hebrew2" | "arabicAlpha" | "arabicAbjad" | "hindiVowels" | "hindiConsonants" | "hindiNumbers" | "hindiCounting" | "thaiLetters" | "thaiNumbers" | "thaiCounting" | "bahtText" | "dollarText" | "custom"; text: string; alignment: "start"; style: { paragraph: { indent: { left: number; }; }; }; }[]; /** * A plugin that enables support for ordered and unordered lists in DOCX. * * @param options - Optional configuration for customizing lists. * @returns An `IPlugin` instance for handling lists in the document. */ export declare const listPlugin: (options?: IListPluginOptions) => IPlugin; export {};