legal-markdown-js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +168 -0
  3. package/dist/browser.d.ts +87 -0
  4. package/dist/browser.d.ts.map +1 -0
  5. package/dist/browser.js +157 -0
  6. package/dist/browser.js.map +1 -0
  7. package/dist/cli/index.d.ts +34 -0
  8. package/dist/cli/index.d.ts.map +1 -0
  9. package/dist/cli/index.js +221 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/cli/service.d.ts +128 -0
  12. package/dist/cli/service.d.ts.map +1 -0
  13. package/dist/cli/service.js +284 -0
  14. package/dist/cli/service.js.map +1 -0
  15. package/dist/constants/index.d.ts +229 -0
  16. package/dist/constants/index.d.ts.map +1 -0
  17. package/dist/constants/index.js +232 -0
  18. package/dist/constants/index.js.map +1 -0
  19. package/dist/core/exporters/metadata-exporter.d.ts +104 -0
  20. package/dist/core/exporters/metadata-exporter.d.ts.map +1 -0
  21. package/dist/core/exporters/metadata-exporter.js +201 -0
  22. package/dist/core/exporters/metadata-exporter.js.map +1 -0
  23. package/dist/core/index.d.ts +40 -0
  24. package/dist/core/index.d.ts.map +1 -0
  25. package/dist/core/index.js +56 -0
  26. package/dist/core/index.js.map +1 -0
  27. package/dist/core/parsers/yaml-parser.d.ts +149 -0
  28. package/dist/core/parsers/yaml-parser.d.ts.map +1 -0
  29. package/dist/core/parsers/yaml-parser.js +321 -0
  30. package/dist/core/parsers/yaml-parser.js.map +1 -0
  31. package/dist/core/processors/clause-processor.d.ts +74 -0
  32. package/dist/core/processors/clause-processor.d.ts.map +1 -0
  33. package/dist/core/processors/clause-processor.js +213 -0
  34. package/dist/core/processors/clause-processor.js.map +1 -0
  35. package/dist/core/processors/date-processor.d.ts +90 -0
  36. package/dist/core/processors/date-processor.d.ts.map +1 -0
  37. package/dist/core/processors/date-processor.js +336 -0
  38. package/dist/core/processors/date-processor.js.map +1 -0
  39. package/dist/core/processors/header-processor.d.ts +104 -0
  40. package/dist/core/processors/header-processor.d.ts.map +1 -0
  41. package/dist/core/processors/header-processor.js +585 -0
  42. package/dist/core/processors/header-processor.js.map +1 -0
  43. package/dist/core/processors/import-processor.d.ts +116 -0
  44. package/dist/core/processors/import-processor.d.ts.map +1 -0
  45. package/dist/core/processors/import-processor.js +236 -0
  46. package/dist/core/processors/import-processor.js.map +1 -0
  47. package/dist/core/processors/mixin-processor.d.ts +93 -0
  48. package/dist/core/processors/mixin-processor.d.ts.map +1 -0
  49. package/dist/core/processors/mixin-processor.js +378 -0
  50. package/dist/core/processors/mixin-processor.js.map +1 -0
  51. package/dist/core/processors/reference-processor.d.ts +115 -0
  52. package/dist/core/processors/reference-processor.d.ts.map +1 -0
  53. package/dist/core/processors/reference-processor.js +273 -0
  54. package/dist/core/processors/reference-processor.js.map +1 -0
  55. package/dist/errors/index.d.ts +234 -0
  56. package/dist/errors/index.d.ts.map +1 -0
  57. package/dist/errors/index.js +267 -0
  58. package/dist/errors/index.js.map +1 -0
  59. package/dist/extensions/batch-processor.d.ts +197 -0
  60. package/dist/extensions/batch-processor.d.ts.map +1 -0
  61. package/dist/extensions/batch-processor.js +392 -0
  62. package/dist/extensions/batch-processor.js.map +1 -0
  63. package/dist/extensions/formatters/index.d.ts +99 -0
  64. package/dist/extensions/formatters/index.d.ts.map +1 -0
  65. package/dist/extensions/formatters/index.js +128 -0
  66. package/dist/extensions/formatters/index.js.map +1 -0
  67. package/dist/extensions/index.d.ts +53 -0
  68. package/dist/extensions/index.d.ts.map +1 -0
  69. package/dist/extensions/index.js +71 -0
  70. package/dist/extensions/index.js.map +1 -0
  71. package/dist/extensions/latex-parser.d.ts +111 -0
  72. package/dist/extensions/latex-parser.d.ts.map +1 -0
  73. package/dist/extensions/latex-parser.js +563 -0
  74. package/dist/extensions/latex-parser.js.map +1 -0
  75. package/dist/extensions/rst-parser.d.ts +112 -0
  76. package/dist/extensions/rst-parser.d.ts.map +1 -0
  77. package/dist/extensions/rst-parser.js +268 -0
  78. package/dist/extensions/rst-parser.js.map +1 -0
  79. package/dist/extensions/template-loops.d.ts +61 -0
  80. package/dist/extensions/template-loops.d.ts.map +1 -0
  81. package/dist/extensions/template-loops.js +418 -0
  82. package/dist/extensions/template-loops.js.map +1 -0
  83. package/dist/extensions/utilities/index.d.ts +114 -0
  84. package/dist/extensions/utilities/index.d.ts.map +1 -0
  85. package/dist/extensions/utilities/index.js +137 -0
  86. package/dist/extensions/utilities/index.js.map +1 -0
  87. package/dist/extensions/validators/index.d.ts +65 -0
  88. package/dist/extensions/validators/index.d.ts.map +1 -0
  89. package/dist/extensions/validators/index.js +88 -0
  90. package/dist/extensions/validators/index.js.map +1 -0
  91. package/dist/generators/html-generator.d.ts +184 -0
  92. package/dist/generators/html-generator.d.ts.map +1 -0
  93. package/dist/generators/html-generator.js +361 -0
  94. package/dist/generators/html-generator.js.map +1 -0
  95. package/dist/generators/pdf-generator.d.ts +165 -0
  96. package/dist/generators/pdf-generator.d.ts.map +1 -0
  97. package/dist/generators/pdf-generator.js +275 -0
  98. package/dist/generators/pdf-generator.js.map +1 -0
  99. package/dist/helpers/date-helpers.d.ts +216 -0
  100. package/dist/helpers/date-helpers.d.ts.map +1 -0
  101. package/dist/helpers/date-helpers.js +402 -0
  102. package/dist/helpers/date-helpers.js.map +1 -0
  103. package/dist/helpers/index.d.ts +87 -0
  104. package/dist/helpers/index.d.ts.map +1 -0
  105. package/dist/helpers/index.js +149 -0
  106. package/dist/helpers/index.js.map +1 -0
  107. package/dist/helpers/number-helpers.d.ts +269 -0
  108. package/dist/helpers/number-helpers.d.ts.map +1 -0
  109. package/dist/helpers/number-helpers.js +406 -0
  110. package/dist/helpers/number-helpers.js.map +1 -0
  111. package/dist/helpers/string-helpers.d.ts +391 -0
  112. package/dist/helpers/string-helpers.d.ts.map +1 -0
  113. package/dist/helpers/string-helpers.js +549 -0
  114. package/dist/helpers/string-helpers.js.map +1 -0
  115. package/dist/index.d.ts +229 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +384 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/legal-markdown.umd.min.js +2 -0
  120. package/dist/legal-markdown.umd.min.js.LICENSE.txt +14 -0
  121. package/dist/legal-markdown.umd.min.js.map +1 -0
  122. package/dist/lib/index.d.ts +150 -0
  123. package/dist/lib/index.d.ts.map +1 -0
  124. package/dist/lib/index.js +265 -0
  125. package/dist/lib/index.js.map +1 -0
  126. package/dist/parsers/content-detector.d.ts +131 -0
  127. package/dist/parsers/content-detector.d.ts.map +1 -0
  128. package/dist/parsers/content-detector.js +220 -0
  129. package/dist/parsers/content-detector.js.map +1 -0
  130. package/dist/parsers/fallback-parsers.d.ts +14 -0
  131. package/dist/parsers/fallback-parsers.d.ts.map +1 -0
  132. package/dist/parsers/fallback-parsers.js +188 -0
  133. package/dist/parsers/fallback-parsers.js.map +1 -0
  134. package/dist/parsers/implementations/pandoc-native.d.ts +13 -0
  135. package/dist/parsers/implementations/pandoc-native.d.ts.map +1 -0
  136. package/dist/parsers/implementations/pandoc-native.js +63 -0
  137. package/dist/parsers/implementations/pandoc-native.js.map +1 -0
  138. package/dist/parsers/implementations/pandoc-wasm.d.ts +14 -0
  139. package/dist/parsers/implementations/pandoc-wasm.d.ts.map +1 -0
  140. package/dist/parsers/implementations/pandoc-wasm.js +64 -0
  141. package/dist/parsers/implementations/pandoc-wasm.js.map +1 -0
  142. package/dist/parsers/pandoc-factory.d.ts +97 -0
  143. package/dist/parsers/pandoc-factory.d.ts.map +1 -0
  144. package/dist/parsers/pandoc-factory.js +146 -0
  145. package/dist/parsers/pandoc-factory.js.map +1 -0
  146. package/dist/parsers/pandoc-loader.d.ts +24 -0
  147. package/dist/parsers/pandoc-loader.d.ts.map +1 -0
  148. package/dist/parsers/pandoc-loader.js +124 -0
  149. package/dist/parsers/pandoc-loader.js.map +1 -0
  150. package/dist/parsers/pandoc-parser.d.ts +27 -0
  151. package/dist/parsers/pandoc-parser.d.ts.map +1 -0
  152. package/dist/parsers/pandoc-parser.js +3 -0
  153. package/dist/parsers/pandoc-parser.js.map +1 -0
  154. package/dist/styles/default.css +125 -0
  155. package/dist/styles/headers.css +146 -0
  156. package/dist/styles/highlight.css +171 -0
  157. package/dist/tracking/field-tracker.d.ts +206 -0
  158. package/dist/tracking/field-tracker.d.ts.map +1 -0
  159. package/dist/tracking/field-tracker.js +247 -0
  160. package/dist/tracking/field-tracker.js.map +1 -0
  161. package/dist/types.d.ts +186 -0
  162. package/dist/types.d.ts.map +1 -0
  163. package/dist/types.js +33 -0
  164. package/dist/types.js.map +1 -0
  165. package/dist/utils/logger.d.ts +107 -0
  166. package/dist/utils/logger.d.ts.map +1 -0
  167. package/dist/utils/logger.js +122 -0
  168. package/dist/utils/logger.js.map +1 -0
  169. package/dist/web/bundle-standalone.js +28 -0
  170. package/dist/web/bundle.js +17 -0
  171. package/dist/web/index.html +1465 -0
  172. package/dist/web/legal-markdown.umd.min.js +2 -0
  173. package/dist/web/standalone.html +390 -0
  174. package/dist/web/styles.css +874 -0
  175. package/package.json +118 -0
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Utility Functions for Legal Document Analysis
4
+ *
5
+ * This module provides utility functions for analyzing and extracting information
6
+ * from Legal Markdown documents. These are extensions beyond the core functionality
7
+ * that provide insights into document structure, content, and usage patterns.
8
+ *
9
+ * Features:
10
+ * - Document statistics and analysis
11
+ * - Reference extraction and analysis
12
+ * - Condition extraction from optional clauses
13
+ * - Word count and character count metrics
14
+ * - Header and structure analysis
15
+ * - Import usage tracking
16
+ * - Extensions not present in the original legal-markdown
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { analyzeDocument, extractReferences, extractConditions } from './utilities';
21
+ *
22
+ * // Analyze document statistics
23
+ * const stats = analyzeDocument(content);
24
+ * console.log(`Document contains ${stats.wordCount} words and ${stats.headerCount} headers`);
25
+ *
26
+ * // Extract references
27
+ * const references = extractReferences(content);
28
+ * console.log('References used:', references);
29
+ *
30
+ * // Extract conditions
31
+ * const conditions = extractConditions(content);
32
+ * console.log('Conditions used:', conditions);
33
+ * ```
34
+ */
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.analyzeDocument = analyzeDocument;
37
+ exports.extractReferences = extractReferences;
38
+ exports.extractConditions = extractConditions;
39
+ // Utility functions - Extensions for utility functions beyond core functionality
40
+ /**
41
+ * Analyzes document statistics and structure
42
+ *
43
+ * Provides comprehensive analysis of Legal Markdown document content including
44
+ * word counts, structural elements, and usage patterns. This is an extension
45
+ * not present in the original legal-markdown specification.
46
+ *
47
+ * @function analyzeDocument
48
+ * @param {string} content - The legal document content to analyze
49
+ * @returns {Object} Object containing document statistics
50
+ * @returns {number} returns.wordCount - Total number of words in the document
51
+ * @returns {number} returns.characterCount - Total number of characters in the document
52
+ * @returns {number} returns.headerCount - Number of header structures (l., ll., etc.)
53
+ * @returns {number} returns.optionalClauseCount - Number of optional clauses found
54
+ * @returns {number} returns.crossReferenceCount - Number of cross-references found
55
+ * @returns {number} returns.importCount - Number of import statements found
56
+ * @example
57
+ * ```typescript
58
+ * import { analyzeDocument } from './utilities';
59
+ *
60
+ * const stats = analyzeDocument(documentContent);
61
+ * console.log(`Document Analysis:`);
62
+ * console.log(`- Words: ${stats.wordCount}`);
63
+ * console.log(`- Characters: ${stats.characterCount}`);
64
+ * console.log(`- Headers: ${stats.headerCount}`);
65
+ * console.log(`- Optional Clauses: ${stats.optionalClauseCount}`);
66
+ * console.log(`- Cross References: ${stats.crossReferenceCount}`);
67
+ * console.log(`- Imports: ${stats.importCount}`);
68
+ * ```
69
+ */
70
+ function analyzeDocument(content) {
71
+ const words = content.split(/\s+/).filter(word => word.length > 0);
72
+ const headers = content.match(/^l+\./gm) || [];
73
+ const optionalClauses = content.match(/\[.*?\]\{.*?\}/g) || [];
74
+ const crossReferences = content.match(/\|.*?\|/g) || [];
75
+ const imports = content.match(/@import\s+/g) || [];
76
+ return {
77
+ wordCount: words.length,
78
+ characterCount: content.length,
79
+ headerCount: headers.length,
80
+ optionalClauseCount: optionalClauses.length,
81
+ crossReferenceCount: crossReferences.length,
82
+ importCount: imports.length,
83
+ };
84
+ }
85
+ /**
86
+ * Extracts all references used in a document
87
+ *
88
+ * Scans the document content for cross-reference patterns and returns a unique
89
+ * list of all references found. Useful for understanding document dependencies
90
+ * and reference usage patterns.
91
+ *
92
+ * @function extractReferences
93
+ * @param {string} content - The legal document content to analyze
94
+ * @returns {string[]} Array of unique reference names found in the document
95
+ * @example
96
+ * ```typescript
97
+ * import { extractReferences } from './utilities';
98
+ *
99
+ * const references = extractReferences(documentContent);
100
+ * console.log('References used in document:', references);
101
+ *
102
+ * // Example output: ['section-1', 'definitions', 'termination-clause']
103
+ * ```
104
+ */
105
+ function extractReferences(content) {
106
+ const references = content.match(/\|(.*?)\|/g) || [];
107
+ return references
108
+ .map(ref => ref.slice(1, -1))
109
+ .filter((ref, index, arr) => arr.indexOf(ref) === index);
110
+ }
111
+ /**
112
+ * Extracts all conditions used in optional clauses
113
+ *
114
+ * Scans the document content for conditional clause patterns and returns a unique
115
+ * list of all conditions found. Useful for understanding document logic and
116
+ * conditional content usage.
117
+ *
118
+ * @function extractConditions
119
+ * @param {string} content - The legal document content to analyze
120
+ * @returns {string[]} Array of unique condition names found in the document
121
+ * @example
122
+ * ```typescript
123
+ * import { extractConditions } from './utilities';
124
+ *
125
+ * const conditions = extractConditions(documentContent);
126
+ * console.log('Conditions used in document:', conditions);
127
+ *
128
+ * // Example output: ['include-warranty', 'corporate-client', 'international-law']
129
+ * ```
130
+ */
131
+ function extractConditions(content) {
132
+ const conditions = content.match(/\{(.*?)\}/g) || [];
133
+ return conditions
134
+ .map(cond => cond.slice(1, -1))
135
+ .filter((cond, index, arr) => arr.indexOf(cond) === index);
136
+ }
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/utilities/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;AAkCH,0CAsBC;AAsBD,8CAKC;AAsBD,8CAKC;AA5GD,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,eAAe,CAAC,OAAe;IAQ7C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAC/C,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;IAC/D,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAEnD,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,MAAM;QACvB,cAAc,EAAE,OAAO,CAAC,MAAM;QAC9B,WAAW,EAAE,OAAO,CAAC,MAAM;QAC3B,mBAAmB,EAAE,eAAe,CAAC,MAAM;QAC3C,mBAAmB,EAAE,eAAe,CAAC,MAAM;QAC3C,WAAW,EAAE,OAAO,CAAC,MAAM;KAC5B,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACrD,OAAO,UAAU;SACd,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC5B,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACrD,OAAO,UAAU;SACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC9B,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @fileoverview Document Validators for Legal Markdown
3
+ *
4
+ * This module provides validation functions for Legal Markdown documents to ensure
5
+ * proper structure, syntax, and content integrity. These validators are extensions
6
+ * beyond the core functionality that help identify potential issues before processing.
7
+ *
8
+ * Features:
9
+ * - Document structure validation
10
+ * - Syntax checking for brackets and braces
11
+ * - Content integrity verification
12
+ * - Error reporting with detailed messages
13
+ * - Extensions not present in the original legal-markdown
14
+ * - Validation rules for legal document conventions
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { validateDocumentStructure } from './validators';
19
+ *
20
+ * // Validate document structure
21
+ * const validation = validateDocumentStructure(content);
22
+ * if (!validation.isValid) {
23
+ * console.error('Document validation failed:');
24
+ * validation.errors.forEach(error => console.error(`- ${error}`));
25
+ * }
26
+ * ```
27
+ */
28
+ /**
29
+ * Validates document structure and content integrity
30
+ *
31
+ * Performs comprehensive validation of Legal Markdown document structure including
32
+ * syntax checking, bracket matching, and content integrity verification. This is
33
+ * an extension not present in the original legal-markdown specification.
34
+ *
35
+ * @function validateDocumentStructure
36
+ * @param {string} content - The legal document content to validate
37
+ * @returns {Object} Validation result object
38
+ * @returns {boolean} returns.isValid - Whether the document passes all validation checks
39
+ * @returns {string[]} returns.errors - Array of validation error messages
40
+ * @example
41
+ * ```typescript
42
+ * import { validateDocumentStructure } from './validators';
43
+ *
44
+ * const validation = validateDocumentStructure(documentContent);
45
+ *
46
+ * if (validation.isValid) {
47
+ * console.log('Document structure is valid');
48
+ * } else {
49
+ * console.error('Document validation failed:');
50
+ * validation.errors.forEach(error => {
51
+ * console.error(`- ${error}`);
52
+ * });
53
+ * }
54
+ *
55
+ * // Example validation errors:
56
+ * // - Document cannot be empty
57
+ * // - Unmatched optional clause brackets
58
+ * // - Unmatched conditional braces
59
+ * ```
60
+ */
61
+ export declare function validateDocumentStructure(content: string): {
62
+ isValid: boolean;
63
+ errors: string[];
64
+ };
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/validators/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CA0BjG"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Document Validators for Legal Markdown
4
+ *
5
+ * This module provides validation functions for Legal Markdown documents to ensure
6
+ * proper structure, syntax, and content integrity. These validators are extensions
7
+ * beyond the core functionality that help identify potential issues before processing.
8
+ *
9
+ * Features:
10
+ * - Document structure validation
11
+ * - Syntax checking for brackets and braces
12
+ * - Content integrity verification
13
+ * - Error reporting with detailed messages
14
+ * - Extensions not present in the original legal-markdown
15
+ * - Validation rules for legal document conventions
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { validateDocumentStructure } from './validators';
20
+ *
21
+ * // Validate document structure
22
+ * const validation = validateDocumentStructure(content);
23
+ * if (!validation.isValid) {
24
+ * console.error('Document validation failed:');
25
+ * validation.errors.forEach(error => console.error(`- ${error}`));
26
+ * }
27
+ * ```
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.validateDocumentStructure = validateDocumentStructure;
31
+ // Document validators - Extensions for validation beyond core functionality
32
+ /**
33
+ * Validates document structure and content integrity
34
+ *
35
+ * Performs comprehensive validation of Legal Markdown document structure including
36
+ * syntax checking, bracket matching, and content integrity verification. This is
37
+ * an extension not present in the original legal-markdown specification.
38
+ *
39
+ * @function validateDocumentStructure
40
+ * @param {string} content - The legal document content to validate
41
+ * @returns {Object} Validation result object
42
+ * @returns {boolean} returns.isValid - Whether the document passes all validation checks
43
+ * @returns {string[]} returns.errors - Array of validation error messages
44
+ * @example
45
+ * ```typescript
46
+ * import { validateDocumentStructure } from './validators';
47
+ *
48
+ * const validation = validateDocumentStructure(documentContent);
49
+ *
50
+ * if (validation.isValid) {
51
+ * console.log('Document structure is valid');
52
+ * } else {
53
+ * console.error('Document validation failed:');
54
+ * validation.errors.forEach(error => {
55
+ * console.error(`- ${error}`);
56
+ * });
57
+ * }
58
+ *
59
+ * // Example validation errors:
60
+ * // - Document cannot be empty
61
+ * // - Unmatched optional clause brackets
62
+ * // - Unmatched conditional braces
63
+ * ```
64
+ */
65
+ function validateDocumentStructure(content) {
66
+ const errors = [];
67
+ // Basic validation rules
68
+ if (!content.trim()) {
69
+ errors.push('Document cannot be empty');
70
+ }
71
+ // Check for unmatched optional clause brackets
72
+ const openBrackets = (content.match(/\[/g) || []).length;
73
+ const closeBrackets = (content.match(/\]/g) || []).length;
74
+ if (openBrackets !== closeBrackets) {
75
+ errors.push('Unmatched optional clause brackets');
76
+ }
77
+ // Check for unmatched conditional braces
78
+ const openBraces = (content.match(/\{/g) || []).length;
79
+ const closeBraces = (content.match(/\}/g) || []).length;
80
+ if (openBraces !== closeBraces) {
81
+ errors.push('Unmatched conditional braces');
82
+ }
83
+ return {
84
+ isValid: errors.length === 0,
85
+ errors,
86
+ };
87
+ }
88
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/validators/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AAqCH,8DA0BC;AA7DD,4EAA4E;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,yBAAyB,CAAC,OAAe;IACvD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,yBAAyB;IACzB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC1C,CAAC;IAED,+CAA+C;IAC/C,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACzD,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1D,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;QACnC,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACpD,CAAC;IAED,yCAAyC;IACzC,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACvD,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxD,IAAI,UAAU,KAAK,WAAW,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * @fileoverview HTML Generation Module for Legal Markdown Documents
3
+ *
4
+ * This module provides functionality to convert processed Legal Markdown content
5
+ * into well-formatted HTML documents with CSS styling, accessibility features,
6
+ * and print optimization.
7
+ *
8
+ * Features:
9
+ * - Markdown to HTML conversion using marked
10
+ * - DOM manipulation with cheerio for enhanced formatting
11
+ * - Custom CSS injection and styling
12
+ * - Field highlighting for document review
13
+ * - Print-friendly output with page break controls
14
+ * - Responsive table handling
15
+ * - Accessibility improvements
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { htmlGenerator } from './html-generator';
20
+ *
21
+ * const html = await htmlGenerator.generateHtml(markdownContent, {
22
+ * title: 'Legal Agreement',
23
+ * cssPath: './styles.css',
24
+ * includeHighlighting: true
25
+ * });
26
+ * ```
27
+ */
28
+ /**
29
+ * Configuration options for HTML generation
30
+ *
31
+ * @interface HtmlGeneratorOptions
32
+ */
33
+ export interface HtmlGeneratorOptions {
34
+ /** Path to custom CSS file to include in the generated HTML */
35
+ cssPath?: string;
36
+ /** Path to highlighting CSS file for field highlighting */
37
+ highlightCssPath?: string;
38
+ /** Whether to include field highlighting styles */
39
+ includeHighlighting?: boolean;
40
+ /** Document title for the HTML page */
41
+ title?: string;
42
+ /** Additional metadata to include in HTML head */
43
+ metadata?: Record<string, string>;
44
+ }
45
+ /**
46
+ * HTML Generator for Legal Markdown Documents
47
+ *
48
+ * Converts processed Legal Markdown content into formatted HTML documents
49
+ * with professional styling, accessibility features, and print optimization.
50
+ *
51
+ * @class HtmlGenerator
52
+ * @example
53
+ * ```typescript
54
+ * const generator = new HtmlGenerator();
55
+ * const html = await generator.generateHtml(content, {
56
+ * title: 'Contract',
57
+ * includeHighlighting: true
58
+ * });
59
+ * ```
60
+ */
61
+ export declare class HtmlGenerator {
62
+ /**
63
+ * Creates a new HTML generator instance and configures the markdown parser
64
+ *
65
+ * @constructor
66
+ */
67
+ constructor();
68
+ /**
69
+ * Configures the marked markdown parser with options optimized for legal documents
70
+ *
71
+ * @private
72
+ * @method configureMarked
73
+ * @returns {void}
74
+ */
75
+ private configureMarked;
76
+ /**
77
+ * Removes YAML frontmatter from markdown content if present
78
+ *
79
+ * @private
80
+ * @method removeYamlFrontmatter
81
+ * @param {string} content - The markdown content that may contain YAML frontmatter
82
+ * @returns {string} Content with YAML frontmatter removed
83
+ * @example
84
+ * ```typescript
85
+ * const content = `---
86
+ * title: Document
87
+ * ---
88
+ * # Content`;
89
+ * const clean = this.removeYamlFrontmatter(content); // "# Content"
90
+ * ```
91
+ */
92
+ private removeYamlFrontmatter;
93
+ /**
94
+ * Generates a complete HTML document from Legal Markdown content
95
+ *
96
+ * This is the main method that orchestrates the conversion process:
97
+ * 1. Removes YAML frontmatter
98
+ * 2. Converts markdown to HTML using marked
99
+ * 3. Applies DOM transformations for legal document formatting
100
+ * 4. Injects custom CSS and styling
101
+ * 5. Builds a complete HTML document
102
+ *
103
+ * @async
104
+ * @method generateHtml
105
+ * @param {string} markdownContent - The processed Legal Markdown content to convert
106
+ * @param {HtmlGeneratorOptions} [options={}] - Configuration options for HTML generation
107
+ * @returns {Promise<string>} A promise that resolves to the complete HTML document
108
+ * @throws {Error} When HTML generation fails due to parsing or file system errors
109
+ * @example
110
+ * ```typescript
111
+ * const html = await generator.generateHtml(
112
+ * '# Contract\n\nThis is a {{party.name}} agreement.',
113
+ * {
114
+ * title: 'Service Agreement',
115
+ * cssPath: './contract-styles.css',
116
+ * includeHighlighting: true,
117
+ * metadata: {
118
+ * author: 'Legal Team',
119
+ * version: '1.0'
120
+ * }
121
+ * }
122
+ * );
123
+ * ```
124
+ */
125
+ generateHtml(markdownContent: string, options?: HtmlGeneratorOptions): Promise<string>;
126
+ /**
127
+ * Applies DOM transformations to enhance the HTML for legal document presentation
128
+ *
129
+ * Transformations include:
130
+ * - Adding no-break classes to short lists for better print layout
131
+ * - Wrapping tables in responsive containers
132
+ * - Adding alt attributes to images for accessibility
133
+ * - Adding print-friendly CSS classes
134
+ * - Cleaning up paragraph tags in list items
135
+ *
136
+ * @private
137
+ * @method applyDomTransformations
138
+ * @param {cheerio.CheerioAPI} $ - The cheerio instance with loaded HTML
139
+ * @returns {void}
140
+ */
141
+ private applyDomTransformations;
142
+ /**
143
+ * Loads CSS content from a file path
144
+ *
145
+ * @private
146
+ * @async
147
+ * @method loadCss
148
+ * @param {string} cssPath - Path to the CSS file to load
149
+ * @returns {Promise<string>} A promise that resolves to the CSS content, or empty string on error
150
+ */
151
+ private loadCss;
152
+ /**
153
+ * Builds a complete HTML document with head, body, and embedded styles
154
+ *
155
+ * Creates a well-formed HTML5 document with:
156
+ * - Proper DOCTYPE and meta tags
157
+ * - Responsive viewport configuration
158
+ * - Embedded CSS styles (base + custom)
159
+ * - SEO-friendly metadata
160
+ * - Print-optimized styling
161
+ *
162
+ * @private
163
+ * @method buildHtmlDocument
164
+ * @param {Object} options - Configuration for building the HTML document
165
+ * @param {string} options.body - The HTML body content
166
+ * @param {string} options.css - Custom CSS to embed
167
+ * @param {string} options.title - Document title
168
+ * @param {Record<string, string>} [options.metadata] - Additional metadata for HTML head
169
+ * @returns {string} Complete HTML document as string
170
+ */
171
+ private buildHtmlDocument;
172
+ }
173
+ /**
174
+ * Singleton instance of HtmlGenerator for convenient importing
175
+ *
176
+ * @constant {HtmlGenerator} htmlGenerator
177
+ * @example
178
+ * ```typescript
179
+ * import { htmlGenerator } from './html-generator';
180
+ * const html = await htmlGenerator.generateHtml(content);
181
+ * ```
182
+ */
183
+ export declare const htmlGenerator: HtmlGenerator;
184
+ //# sourceMappingURL=html-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-generator.d.ts","sourceRoot":"","sources":["../../src/generators/html-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAa;IACxB;;;;OAIG;;IAKH;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,qBAAqB;IA0B7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,YAAY,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiEhG;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,uBAAuB;IAgC/B;;;;;;;;OAQG;YACW,OAAO;IAWrB;;;;;;;;;;;;;;;;;;OAkBG;YACW,iBAAiB;CAwChC;AAED;;;;;;;;;GASG;AAEH,eAAO,MAAM,aAAa,eAAsB,CAAC"}