UNPKG

legal-markdown-js

Version:

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

93 lines 3.68 kB
/** * Date Processing Module for Legal Markdown Documents * * This module provides comprehensive date processing functionality for Legal Markdown * documents, supporting the `@today` syntax with various formatting options. It handles * different date formats, timezones, locales, and provides specialized formatting * for legal documents including ordinal suffixes and custom format patterns. * * Features: * - `@today` syntax for current date insertion * - Format override support: `@today[format]` * - Multiple predefined formats (ISO, US, European, legal, etc.) * - Custom format pattern parsing (YYYY-MM-DD, etc.) * - Timezone and locale support * - Ordinal suffix generation for legal formats * - Graceful error handling with fallback formatting * - Integration with metadata for default settings * * @example * ```typescript * import { processDateReferences } from './date-processor.js'; * * const content = ` * This document is dated @today. * Contract effective date: @today[long] * Expiration: @today[YYYY-MM-DD] * Legal format: @today[legal] * `; * * const metadata = { * 'date-format': 'ISO', * 'timezone': 'America/New_York', * 'locale': 'en-US' * }; * * const processed = processDateReferences(content, metadata); * console.log(processed); * // Output: * // This document is dated 2024-01-15. * // Contract effective date: January 15, 2024 * // Expiration: 2024-01-15 * // Legal format: January 15th, 2024 * ``` */ /** * Date format options that can be specified in YAML front matter * * @interface DateFormatOptions */ export interface DateFormatOptions { /** Default date format to use (ISO, US, European, legal, long, medium, short, or custom pattern) */ dateFormat?: string; /** Timezone identifier (e.g., 'America/New_York', 'Europe/London', 'UTC') */ timezone?: string; /** Locale identifier for formatting (e.g., 'en-US', 'en-GB', 'de-DE') */ locale?: string; } /** * Processes special date references in legal documents * * This is the main function that processes `@today` references in Legal Markdown * documents. It supports format overrides and uses metadata settings for * default formatting, timezone, and locale preferences. * * @deprecated This function is deprecated and will be removed in v4.0.0. * Use `processLegalMarkdownWithRemark()` with the `remarkDates` plugin instead. * The remark-based approach provides better AST processing and date handling. * @see {@link https://github.com/yourrepo/legal-markdown-js/blob/main/docs/migration-guide.md Migration Guide} * * @param {string} content - The document content containing `@today` references * @param {Record<string, any>} metadata - Document metadata with date formatting options * @returns {string} Processed content with `@today` references replaced by formatted dates * @example * ```typescript * // Basic usage with default format * const content1 = "Document dated `@today`"; * const result1 = processDateReferences(content1, {}); * // Output: "Document dated 2024-01-15" * * // Format override * const content2 = "Contract effective `@today[long]`"; * const result2 = processDateReferences(content2, {}); * // Output: "Contract effective January 15, 2024" * * // Using metadata settings * const content3 = "Generated `@today`"; * const metadata = { 'date-format': 'legal', 'timezone': 'America/New_York' }; * const result3 = processDateReferences(content3, metadata); * // Output: "Generated January 15th, 2024" * ``` */ export declare function processDateReferences(content: string, metadata: Record<string, unknown>): string; //# sourceMappingURL=date-processor.d.ts.map