UNPKG

legal-markdown-js

Version:

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

110 lines 3.74 kB
/** * @fileoverview LaTeX Parser Extension for Legal Markdown * * This module provides functionality to parse LaTeX (.tex) documents and convert * them to Legal Markdown format. It uses Pandoc for robust parsing with intelligent * fallback to basic regex-based parsing when Pandoc is not available or fails. * * Features: * - AST-based LaTeX parsing using Pandoc * - Fallback regex-based parsing for simple documents * - Content type detection and validation * - Section command conversion to Legal Markdown headers * - Text formatting preservation (textbf, textit, emph) * - Environment handling (enumerate, itemize, verbatim) * - Macro expansion and command processing * - Mathematical notation preservation * - Reference and label handling * * @example * ```typescript * import { convertLatexToLegalMarkdown, convertLatexToLegalMarkdownSync } from './latex-parser'; * * const latexContent = ` * \\documentclass{article} * \\begin{document} * * \\section{Introduction} * This is a sample LaTeX document with \\textbf{bold} and \\textit{italic} text. * * \\subsection{Terms} * Some content here. * * \\end{document} * `; * * // Async conversion (preferred) * const legalMarkdown = await convertLatexToLegalMarkdown(latexContent); * * // Sync conversion (fallback) * const legalMarkdownSync = convertLatexToLegalMarkdownSync(latexContent); * ``` */ /** * Converts LaTeX content to legal markdown format using pandoc */ export declare function parseLatex(content: string): Promise<string>; /** * Synchronous version using fallback parser */ export declare function parseLatexSync(content: string): string; /** * Checks if content appears to be LaTeX */ export declare function isLatex(content: string): boolean; /** * Converts LaTeX content to Legal Markdown format (async version) * * This function provides robust conversion of LaTeX documents to Legal Markdown * format using Pandoc when available. It automatically detects LaTeX content * and only performs conversion when necessary, preserving non-LaTeX content unchanged. * * @param {string} content - The input content that may contain LaTeX * @returns {Promise<string>} A promise that resolves to Legal Markdown formatted content * @example * ```typescript * const latexContent = ` * \\section{Introduction} * This is a sample LaTeX document with \\textbf{bold} text. * * \\subsection{Terms} * Some content with \\textit{italic} formatting. * `; * * const legalMarkdown = await convertLatexToLegalMarkdown(latexContent); * console.log(legalMarkdown); * // Output: * // l. Introduction * // This is a sample LaTeX document with **bold** text. * // * // ll. Terms * // Some content with *italic* formatting. * ``` */ export declare function convertLatexToLegalMarkdown(content: string): Promise<string>; /** * Converts LaTeX content to Legal Markdown format (sync version) * * This synchronous function provides fallback conversion of LaTeX documents * using regex-based parsing when Pandoc is not available. It's designed for * environments where async operations are not suitable or when simple * conversion is sufficient. * * @param {string} content - The input content that may contain LaTeX * @returns {string} Legal Markdown formatted content * @example * ```typescript * const latexContent = ` * \\section{Terms} * This agreement contains \\textbf{important} terms. * `; * * const legalMarkdown = convertLatexToLegalMarkdownSync(latexContent); * console.log(legalMarkdown); * // Output: * // l. Terms * // This agreement contains **important** terms. * ``` */ export declare function convertLatexToLegalMarkdownSync(content: string): string; //# sourceMappingURL=latex-parser.d.ts.map