UNPKG

@m2d/core

Version:

Core engine to convert extended MDAST to DOCX. Supports plugins for footnotes, images, lists, tables, and more. Designed for seamless Markdown-to-DOCX conversion.

26 lines (25 loc) 1.39 kB
import { type OutputType } from "docx"; import type { Root } from "mdast"; import { type IDocxProps, type ISectionProps } from "./utils"; /** * Represents the input Markdown AST tree(s) for conversion. * Supports either: * - A single `Root` node (direct conversion) * - An array of objects `{ ast: Root, props?: ISectionProps }` for fine-grained section-level control. */ type IInputMDAST = Root | { ast: Root; props?: ISectionProps; }[]; /** * Converts an MDAST (Markdown Abstract Syntax Tree) into a DOCX document. * @param astInputs - A single or multiple MDAST trees with optional section properties. * @param docxProps - General document properties. @see https://docx.js.org/#/usage/document * @param defaultSectionProps - Default properties for each document section. @see https://docx.js.org/#/usage/sections * @param outputType - The desired output format (default: `"blob"`). @see https://docx.js.org/#/usage/packers * @returns A DOCX document in the specified format. */ export declare const toDocx: (astInputs: IInputMDAST, docxProps?: IDocxProps, defaultSectionProps?: ISectionProps, outputType?: OutputType) => Promise<string | readonly number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | Blob | Buffer<ArrayBufferLike>>; export type { ISectionProps, IDocxProps, IInputMDAST }; export type * from "@m2d/mdast"; export type { IPlugin } from "./utils";