UNPKG

markmv

Version:

TypeScript CLI for markdown file operations with intelligent link refactoring

148 lines 4.37 kB
import type { ConvertOperationOptions, OperationResult } from '../types/operations.js'; /** * Core class for converting markdown link formats and path resolution. * * Provides comprehensive link conversion functionality including path resolution changes * (absolute/relative) and link style transformations between different markdown syntaxes. * * @category Core * * @example * Basic link conversion * ```typescript * const converter = new LinkConverter(); * * // Convert all links to relative paths and wikilink style * const result = await converter.convertFile('document.md', { * pathResolution: 'relative', * linkStyle: 'wikilink', * basePath: process.cwd() * }); * ``` */ export declare class LinkConverter { private parser; constructor(); /** * Convert links in a single markdown file. * * @param filePath - Path to the markdown file to convert * @param options - Conversion options specifying target format * * @returns Promise resolving to operation result with conversion details */ convertFile(filePath: string, options: ConvertOperationOptions): Promise<OperationResult>; /** * Convert links in multiple markdown files. * * @param filePaths - Array of file paths to convert * @param options - Conversion options specifying target format * * @returns Promise resolving to combined operation result */ convertFiles(filePaths: string[], options: ConvertOperationOptions): Promise<OperationResult>; /** * Convert markdown content with specified link transformations. * * @private * * @param content - Original markdown content * @param links - Parsed link information * @param filePath - Path of the source file (for relative path calculations) * @param options - Conversion options * * @returns Promise resolving to converted content */ private convertContent; /** * Transform a link node according to conversion options. * * @private * * @param node - The link/image node to transform * @param filePath - Source file path for relative calculations * @param options - Conversion options * * @returns Whether the node was modified */ private transformLinkNode; /** * Transform text-based links (like Claude imports). * * @private * * @param node - Text node that might contain text-based links * @param filePath - Source file path for relative calculations * @param options - Conversion options * * @returns Whether the node was modified */ private transformTextLinks; /** * Convert path resolution between absolute and relative formats. * * @private * * @param linkPath - Original link path * @param sourceFile - Path of the file containing the link * @param targetResolution - Target path resolution type * @param basePath - Base path for absolute resolution calculations * * @returns Converted path */ private convertPathResolution; /** * Convert link style format. * * @private * * @param node - Link node to convert * @param targetStyle - Target link style * * @returns Whether the node was modified */ private convertLinkStyle; /** * Detect changes between original and converted content. * * @private * * @param original - Original content * @param converted - Converted content * @param filePath - File path for change tracking * * @returns Array of detected changes */ private detectChanges; /** * Check if a node is a link or image node. * * @private * * @param node - Node to check * * @returns Whether the node is a link node */ private isLinkNode; /** * Check if a node is a text node. * * @private * * @param node - Node to check * * @returns Whether the node is a text node */ private isTextNode; /** * Check if a URL represents an internal link. * * @private * * @param url - URL to check * * @returns Whether the URL is an internal link */ private isInternalLink; } //# sourceMappingURL=link-converter.d.ts.map