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.38 kB
/** * YAML Front Matter Auto-Population Module for Legal Markdown Documents * * This module provides functionality to auto-populate YAML front matter with inferred * header level patterns and processing properties following the original Legal Markdown * specification. It analyzes document structure and generates enhanced metadata. * * Features: * - Document structure analysis for header level inference * - Auto-population of missing header level definitions * - Properties section generation (no-indent, no-reset, level-style) * - YAML front matter enhancement and standardization * - Support for both traditional (l., ll., lll.) and alternative syntax * * @example * ```typescript * import { autoPopulateYamlFrontMatter } from './yaml-auto-population'; * * const content = `--- * level-1: "Article 1." * level-2: "Section 1." * --- * l. Introduction * ll. Terms`; * * const enhanced = autoPopulateYamlFrontMatter(content); * // Returns document with enhanced YAML front matter including * // all level definitions and Properties section * ``` * * @module */ /** * Configuration for YAML auto-population */ interface YamlAutoPopulationOptions { /** Whether to add Properties section with processing configurations */ includeProperties?: boolean; /** Whether to infer missing header levels from document content */ inferMissingLevels?: boolean; /** Whether to ensure all level definitions are properly quoted */ ensureQuotedLevels?: boolean; } /** * Default header level patterns following Legal Markdown conventions * * For complete documentation on header formats and variable usage, see: * @see {@link ../../../docs/headers_numbering.md} - Complete guide to headers and numbering system */ /** * Auto-populates YAML front matter with inferred header patterns and properties * * Analyzes the document structure and enhances the YAML front matter with: * - Missing header level definitions * - Properties section with processing configurations * - Properly quoted level definitions * * @param {string} content - The document content with YAML front matter * @param {YamlAutoPopulationOptions} [options={}] - Configuration options * @returns {string} Document with enhanced YAML front matter * @example * ```typescript * const input = `--- * level-1: "Article 1." * --- * l. Introduction * ll. Terms`; * * const result = autoPopulateYamlFrontMatter(input); * // Returns document with complete level definitions and Properties section * ``` */ export declare function autoPopulateYamlFrontMatter(content: string, options?: YamlAutoPopulationOptions): string; /** * Generates appropriate no-indent pattern based on document analysis * * @private * @param {string} content - Document content to analyze * @returns {string} Comma-separated no-indent pattern */ export declare function generateNoIndentPattern(content: string): string; /** * Validates and normalizes YAML front matter structure * * Ensures the YAML front matter follows the expected structure with * proper sectioning and formatting. * * @param {Record<string, any>} metadata - Metadata to validate * @returns {Record<string, any>} Normalized metadata */ export declare function normalizeYamlStructure(metadata: Record<string, any>): Record<string, any>; export {}; //# sourceMappingURL=yaml-auto-population.d.ts.map