UNPKG

legal-markdown-js

Version:

Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version

65 lines 2.12 kB
/** * Remark plugin for Legal Markdown cross-references * * This plugin processes internal cross-references in Legal Markdown documents * using AST-based processing to avoid text contamination issues. It handles: * - Header extraction with |key| syntax (l. **Title** |key|) * - Section numbering based on frontmatter formats * - Cross-reference resolution throughout the document * - Integration with field tracking for highlighting * * Architecture: * 1. First pass: Extract cross-reference definitions from headers * 2. Generate section numbers based on legal numbering formats * 3. Second pass: Replace |key| references with section numbers * 4. Integrate with field tracker for highlighting support * * @example * ```typescript * import { unified } from 'unified'; * import remarkParse from 'remark-parse'; * import remarkCrossReferences from './cross-references'; * * const processor = unified() * .use(remarkParse) * .use(remarkCrossReferences, { metadata: frontmatterData }); * * const result = await processor.process(content); * ``` * * @module */ import type { Plugin } from 'unified'; import type { Root } from 'mdast'; /** * Cross-reference definition extracted from headers */ interface CrossReferenceDefinition { key: string; level: number; sectionNumber: string; sectionText: string; headerText: string; position?: { line: number; column: number; }; } /** * Plugin options for cross-reference processing */ interface CrossReferenceOptions { /** Document metadata containing level formats and other data */ metadata: Record<string, any>; /** Enable debug logging */ debug?: boolean; /** Enable field tracking with highlighting during AST processing */ enableFieldTracking?: boolean; } /** * Remark plugin for processing cross-references in Legal Markdown documents */ declare const remarkCrossReferences: Plugin<[CrossReferenceOptions], Root>; export default remarkCrossReferences; export type { CrossReferenceOptions, CrossReferenceDefinition }; //# sourceMappingURL=cross-references.d.ts.map