UNPKG

legal-markdown-js

Version:

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

76 lines 3.1 kB
/** * Optional Clause Processing Module for Legal Markdown Documents * * This module provides functionality to process conditional clauses in Legal Markdown * documents, allowing for dynamic content inclusion based on metadata conditions. * It supports complex boolean logic with AND/OR operations, equality comparisons, * and nested value access for sophisticated document customization. * * Features: * - Conditional clause syntax: [content]{condition} * - Boolean logic with AND/OR operations * - Equality and inequality comparisons * - Nested metadata value access with dot notation * - Type-aware value comparison (strings, numbers, booleans) * - Graceful error handling for invalid conditions * - Support for quoted string values in conditions * * @example * ```typescript * import { processOptionalClauses } from './clause-processor'; * * const content = ` * This agreement [includes confidentiality clauses]{confidentiality} * [and has a termination period of {{termination_days}} days]{termination_days} * [with special provisions for European clients]{client.region = "EU"}. * `; * * const metadata = { * confidentiality: true, * termination_days: 30, * client: { region: "EU" } * }; * * const processed = processOptionalClauses(content, metadata); * console.log(processed); * // Output: * // This agreement includes confidentiality clauses * // and has a termination period of 30 days * // with special provisions for European clients. * ``` * * @module */ /** * Processes optional clauses in a LegalMarkdown document * * Evaluates conditional clauses using the syntax [content]{condition} and includes * or excludes content based on metadata values. Supports complex boolean logic * and various comparison operators for sophisticated document customization. * * @param {string} content - The document content containing optional clauses * @param {Record<string, any>} metadata - Document metadata with clause conditions * @returns {string} Processed content with conditional clauses evaluated * @example * ```typescript * // Simple boolean condition * const content1 = '[This clause is included]{include_special}'; * const metadata1 = { include_special: true }; * const result1 = processOptionalClauses(content1, metadata1); * // Output: "This clause is included" * * // Complex condition with AND/OR logic * const content2 = '[Premium features available]{premium = true AND region != "restricted"}'; * const metadata2 = { premium: true, region: "US" }; * const result2 = processOptionalClauses(content2, metadata2); * // Output: "Premium features available" * * // Nested metadata access * const content3 = '[European compliance required]{client.location.country = "DE"}'; * const metadata3 = { client: { location: { country: "DE" } } }; * const result3 = processOptionalClauses(content3, metadata3); * // Output: "European compliance required" * ``` */ export declare function processOptionalClauses(content: string, metadata: Record<string, any>): string; //# sourceMappingURL=clause-processor.d.ts.map