@aidalinfo/office-to-markdown
Version:
Modern TypeScript library for converting Office documents (DOCX) to Markdown format, optimized for Bun runtime with enhanced table support and math equation conversion.
97 lines • 2.73 kB
TypeScript
import type { ReadableStream } from "node:stream/web";
import type { DocumentConverterResult } from "./result.js";
import type { StreamInfo } from "./stream-info.js";
/**
* Options for document conversion.
*/
export interface ConverterOptions {
/**
* Custom style map for mammoth conversion (DOCX specific)
*/
styleMap?: string;
/**
* Whether to preserve tables in the output
*/
preserveTables?: boolean;
/**
* Whether to convert math equations to LaTeX
*/
convertMath?: boolean;
/**
* Custom heading style for Markdown output
*/
headingStyle?: "atx" | "setext";
/**
* Additional options passed to underlying converters
*/
[key: string]: any;
}
/**
* Interface for file-like objects that can be converted.
*/
export interface FileSource {
/**
* Read the entire file as a buffer
*/
arrayBuffer(): Promise<ArrayBuffer>;
/**
* Get the file size in bytes
*/
size?: number;
/**
* Get the file name
*/
name?: string;
/**
* Get the file type/MIME type
*/
type?: string;
}
/**
* Union type for all supported input sources
*/
export type ConvertibleSource = string | Buffer | ArrayBuffer | Uint8Array | FileSource | ReadableStream<Uint8Array>;
/**
* Exception thrown when a conversion fails
*/
export declare class FileConversionException extends Error {
originalError?: Error | undefined;
constructor(message: string, originalError?: Error | undefined);
}
/**
* Exception thrown when a required dependency is missing
*/
export declare class MissingDependencyException extends Error {
constructor(message: string);
}
/**
* Exception thrown when a file format is not supported
*/
export declare class UnsupportedFormatException extends Error {
constructor(message: string);
}
/**
* Common interface for all file converters
*/
export interface IDocumentConverter {
/** Check if this converter can handle the given file */
accepts(buffer: Buffer, streamInfo: StreamInfo): boolean;
/** Convert the file to Markdown */
convert(buffer: Buffer, streamInfo: StreamInfo, options?: ConverterOptions): Promise<DocumentConverterResult>;
/** Get information about this converter's capabilities */
getConversionInfo(): ConverterInfo;
}
/**
* Information about a converter's capabilities
*/
export interface ConverterInfo {
/** Supported file extensions */
supportedExtensions: string[];
/** Supported MIME types */
supportedMimeTypes: string[];
/** List of features this converter supports */
features: string[];
/** Converter name/identifier */
name?: string;
}
//# sourceMappingURL=converter.d.ts.map