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,402 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Date Manipulation and Formatting Helpers
4
+ *
5
+ * This module provides comprehensive date manipulation and formatting utilities
6
+ * specifically designed for legal documents. It includes functions for date
7
+ * arithmetic, parsing, and formatting with legal-specific date formats.
8
+ *
9
+ * Features:
10
+ * - Date arithmetic (add years, months, days)
11
+ * - Flexible date formatting with multiple format options
12
+ * - Legal-specific date formats (formal, ordinal, etc.)
13
+ * - Date parsing with format detection
14
+ * - Comprehensive error handling for invalid dates
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { formatDate, addYears, DateFormats } from './date-helpers';
19
+ *
20
+ * // Format a date for legal documents
21
+ * const legalDate = formatDate(new Date(), DateFormats.LEGAL);
22
+ * // Result: "16th day of July, 2025"
23
+ *
24
+ * // Add years to a contract date
25
+ * const expiryDate = addYears('2025-01-01', 5);
26
+ * ```
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.DateFormats = void 0;
30
+ exports.addYears = addYears;
31
+ exports.addDays = addDays;
32
+ exports.addMonths = addMonths;
33
+ exports.formatDate = formatDate;
34
+ exports.parseDate = parseDate;
35
+ /**
36
+ * Adds a specified number of years to a date
37
+ *
38
+ * This function handles both Date objects and ISO date strings, making it
39
+ * useful for contract calculations and legal document date processing.
40
+ *
41
+ * @param {Date | string} date - The base date as a Date object or ISO string
42
+ * @param {number} years - The number of years to add (can be negative)
43
+ * @returns {Date} A new Date object with the years added
44
+ * @throws {Error} If the input date is invalid
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Add 5 years to a contract start date
49
+ * const startDate = new Date('2025-01-01');
50
+ * const endDate = addYears(startDate, 5);
51
+ * // Result: Date object for 2030-01-01
52
+ *
53
+ * // Using with string input
54
+ * const futureDate = addYears('2025-07-16', 2);
55
+ * // Result: Date object for 2027-07-16
56
+ *
57
+ * // Subtract years (negative input)
58
+ * const pastDate = addYears(new Date(), -3);
59
+ * ```
60
+ */
61
+ function addYears(date, years) {
62
+ if (!date) {
63
+ throw new Error('Date is required for addYears');
64
+ }
65
+ const d = typeof date === 'string' ? new Date(date) : new Date(date);
66
+ if (isNaN(d.getTime())) {
67
+ throw new Error(`Invalid date: ${date}`);
68
+ }
69
+ d.setFullYear(d.getFullYear() + years);
70
+ return d;
71
+ }
72
+ /**
73
+ * Adds a specified number of days to a date
74
+ *
75
+ * Useful for calculating deadlines, notice periods, and other time-sensitive
76
+ * legal requirements in contracts and legal documents.
77
+ *
78
+ * @param {Date | string} date - The base date as a Date object or ISO string
79
+ * @param {number} days - The number of days to add (can be negative)
80
+ * @returns {Date} A new Date object with the days added
81
+ * @throws {Error} If the input date is invalid
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // Add 30 days for a notice period
86
+ * const noticeDate = addDays(new Date(), 30);
87
+ *
88
+ * // Calculate deadline from string date
89
+ * const deadline = addDays('2025-07-16', 14);
90
+ * // Result: Date object for 2025-07-30
91
+ *
92
+ * // Go back in time (negative days)
93
+ * const pastDate = addDays(new Date(), -7);
94
+ * ```
95
+ */
96
+ function addDays(date, days) {
97
+ if (!date) {
98
+ throw new Error('Date is required for addDays');
99
+ }
100
+ const d = typeof date === 'string' ? new Date(date) : new Date(date);
101
+ if (isNaN(d.getTime())) {
102
+ throw new Error(`Invalid date: ${date}`);
103
+ }
104
+ d.setDate(d.getDate() + days);
105
+ return d;
106
+ }
107
+ /**
108
+ * Adds a specified number of months to a date
109
+ *
110
+ * Handles month boundaries intelligently, useful for calculating quarterly
111
+ * reports, monthly payments, and other periodic legal obligations.
112
+ *
113
+ * @param {Date | string} date - The base date as a Date object or ISO string
114
+ * @param {number} months - The number of months to add (can be negative)
115
+ * @returns {Date} A new Date object with the months added
116
+ * @throws {Error} If the input date is invalid
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // Add 6 months for a review period
121
+ * const reviewDate = addMonths(new Date('2025-01-31'), 6);
122
+ * // Result: Date object for 2025-07-31
123
+ *
124
+ * // Calculate quarterly dates
125
+ * const quarterlyDate = addMonths('2025-01-01', 3);
126
+ * // Result: Date object for 2025-04-01
127
+ *
128
+ * // Previous months (negative input)
129
+ * const previousQuarter = addMonths(new Date(), -3);
130
+ * ```
131
+ */
132
+ function addMonths(date, months) {
133
+ if (!date) {
134
+ throw new Error('Date is required for addMonths');
135
+ }
136
+ const d = typeof date === 'string' ? new Date(date) : new Date(date);
137
+ if (isNaN(d.getTime())) {
138
+ throw new Error(`Invalid date: ${date}`);
139
+ }
140
+ d.setMonth(d.getMonth() + months);
141
+ return d;
142
+ }
143
+ /**
144
+ * Formats a date using customizable format strings
145
+ *
146
+ * Provides flexible date formatting with support for multiple format tokens.
147
+ * Particularly useful for legal documents that require specific date formats
148
+ * for different jurisdictions and document types.
149
+ *
150
+ * @param {Date | string} date - The date to format as a Date object or ISO string
151
+ * @param {string} format - The format string (default: 'YYYY-MM-DD')
152
+ * @returns {string} The formatted date string
153
+ * @throws {Error} If the input date is invalid
154
+ *
155
+ * Format tokens:
156
+ * - YYYY: 4-digit year (2025)
157
+ * - YY: 2-digit year (25)
158
+ * - MMMM: Full month name (January)
159
+ * - MMM: Abbreviated month name (Jan)
160
+ * - MM: 2-digit month (01)
161
+ * - M: Month number (1)
162
+ * - DD: 2-digit day (01)
163
+ * - D: Day number (1)
164
+ * - Do: Ordinal day (1st, 2nd, 3rd)
165
+ * - dddd: Full day name (Monday)
166
+ * - ddd: Abbreviated day name (Mon)
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * const date = new Date('2025-07-16');
171
+ *
172
+ * // Standard formats
173
+ * formatDate(date, 'YYYY-MM-DD'); // "2025-07-16"
174
+ * formatDate(date, 'MM/DD/YYYY'); // "07/16/2025"
175
+ * formatDate(date, 'DD/MM/YYYY'); // "16/07/2025"
176
+ *
177
+ * // Legal document formats
178
+ * formatDate(date, DateFormats.LEGAL); // "16th day of July, 2025"
179
+ * formatDate(date, DateFormats.FORMAL); // "Wednesday, July 16th, 2025"
180
+ *
181
+ * // Custom format
182
+ * formatDate(date, 'MMMM Do, YYYY'); // "July 16th, 2025"
183
+ * ```
184
+ */
185
+ function formatDate(date, format = 'YYYY-MM-DD') {
186
+ if (!date) {
187
+ throw new Error('Date is required for formatting');
188
+ }
189
+ const d = typeof date === 'string' ? new Date(date) : date;
190
+ if (isNaN(d.getTime())) {
191
+ throw new Error(`Invalid date: ${date}`);
192
+ }
193
+ const year = d.getFullYear();
194
+ const month = String(d.getMonth() + 1).padStart(2, '0');
195
+ const day = String(d.getDate()).padStart(2, '0');
196
+ const monthNames = [
197
+ 'January',
198
+ 'February',
199
+ 'March',
200
+ 'April',
201
+ 'May',
202
+ 'June',
203
+ 'July',
204
+ 'August',
205
+ 'September',
206
+ 'October',
207
+ 'November',
208
+ 'December',
209
+ ];
210
+ const monthNamesShort = [
211
+ 'Jan',
212
+ 'Feb',
213
+ 'Mar',
214
+ 'Apr',
215
+ 'May',
216
+ 'Jun',
217
+ 'Jul',
218
+ 'Aug',
219
+ 'Sep',
220
+ 'Oct',
221
+ 'Nov',
222
+ 'Dec',
223
+ ];
224
+ const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
225
+ const dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
226
+ // Common date format replacements
227
+ const replacements = {
228
+ YYYY: String(year),
229
+ YY: String(year).slice(-2),
230
+ MM: month,
231
+ M: String(d.getMonth() + 1),
232
+ DD: day,
233
+ D: String(d.getDate()),
234
+ MMMM: monthNames[d.getMonth()],
235
+ MMM: monthNamesShort[d.getMonth()],
236
+ dddd: dayNames[d.getDay()],
237
+ ddd: dayNamesShort[d.getDay()],
238
+ Do: day + getOrdinalSuffix(d.getDate()),
239
+ };
240
+ // Replace tokens in order of length (longest first) to avoid partial replacements
241
+ // Use a single pass approach where we process tokens by length to prevent overlaps
242
+ let formatted = format;
243
+ // Helper function to check if a token is standalone (not part of a longer token)
244
+ function isStandaloneToken(str, token) {
245
+ let pos = 0;
246
+ while (pos <= str.length - token.length) {
247
+ const idx = str.indexOf(token, pos);
248
+ if (idx === -1)
249
+ break;
250
+ // Check if this occurrence is standalone (not part of a longer token)
251
+ const beforeChar = idx > 0 ? str[idx - 1] : '';
252
+ const afterChar = idx + token.length < str.length ? str[idx + token.length] : '';
253
+ // For format tokens, check if it's surrounded by non-token characters
254
+ if (beforeChar !== token[0] && afterChar !== token[0]) {
255
+ return true;
256
+ }
257
+ pos = idx + 1;
258
+ }
259
+ return false;
260
+ }
261
+ // Define tokens in explicit order of replacement to avoid conflicts
262
+ const orderedTokens = [
263
+ 'dddd',
264
+ 'ddd', // Day names (must come before DD/D)
265
+ 'MMMM',
266
+ 'MMM', // Month names (must come before MM/M)
267
+ 'YYYY',
268
+ 'YY', // Years
269
+ 'Do', // Ordinal days (must come before DD/D)
270
+ 'DD',
271
+ 'MM', // Two-digit day/month
272
+ 'D',
273
+ 'M', // Single-digit day/month (must come last)
274
+ ];
275
+ for (const token of orderedTokens) {
276
+ if (replacements[token] && isStandaloneToken(format, token)) {
277
+ // Replace all occurrences of this token at once
278
+ formatted = formatted.split(token).join(replacements[token]);
279
+ }
280
+ }
281
+ return formatted;
282
+ }
283
+ /**
284
+ * Gets the ordinal suffix for a number (1st, 2nd, 3rd, etc.)
285
+ *
286
+ * Internal helper function used by formatDate to add ordinal suffixes
287
+ * to day numbers in formatted dates.
288
+ *
289
+ * @private
290
+ * @param {number} n - The number to get the ordinal suffix for
291
+ * @returns {string} The ordinal suffix ('st', 'nd', 'rd', or 'th')
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * getOrdinalSuffix(1); // 'st'
296
+ * getOrdinalSuffix(2); // 'nd'
297
+ * getOrdinalSuffix(3); // 'rd'
298
+ * getOrdinalSuffix(4); // 'th'
299
+ * getOrdinalSuffix(21); // 'st'
300
+ * ```
301
+ */
302
+ function getOrdinalSuffix(n) {
303
+ const s = ['th', 'st', 'nd', 'rd'];
304
+ const v = n % 100;
305
+ return s[(v - 20) % 10] || s[v] || s[0];
306
+ }
307
+ /**
308
+ * Predefined date format constants for common legal document formats
309
+ *
310
+ * This object provides commonly used date formats in legal documents,
311
+ * making it easy to maintain consistency across different document types.
312
+ *
313
+ * @constant {Object} DateFormats
314
+ * @example
315
+ * ```typescript
316
+ * import { formatDate, DateFormats } from './date-helpers';
317
+ *
318
+ * const date = new Date('2025-07-16');
319
+ *
320
+ * // Use predefined formats
321
+ * formatDate(date, DateFormats.LEGAL); // "16th day of July, 2025"
322
+ * formatDate(date, DateFormats.FORMAL); // "Wednesday, July 16th, 2025"
323
+ * formatDate(date, DateFormats.US); // "07/16/2025"
324
+ * formatDate(date, DateFormats.EU); // "16/07/2025"
325
+ * ```
326
+ */
327
+ exports.DateFormats = {
328
+ ISO: 'YYYY-MM-DD',
329
+ US: 'MM/DD/YYYY',
330
+ EU: 'DD/MM/YYYY',
331
+ UK: 'DD/MM/YYYY',
332
+ FULL: 'MMMM Do, YYYY',
333
+ FULL_US: 'MMMM D, YYYY',
334
+ SHORT: 'MMM D, YYYY',
335
+ LEGAL: 'Do day of MMMM, YYYY',
336
+ FORMAL: 'dddd, MMMM Do, YYYY',
337
+ };
338
+ /**
339
+ * Parses date strings in various formats and returns a Date object
340
+ *
341
+ * Attempts to parse date strings in multiple common formats with intelligent
342
+ * format detection. Useful for processing user input or parsing dates from
343
+ * various document formats.
344
+ *
345
+ * @param {string} dateStr - The date string to parse
346
+ * @returns {Date | null} The parsed Date object, or null if parsing fails
347
+ *
348
+ * Supported formats:
349
+ * - ISO format: YYYY-MM-DD
350
+ * - US format: MM/DD/YYYY
351
+ * - European format: DD/MM/YYYY
352
+ * - Alternative separators: MM-DD-YYYY, DD-MM-YYYY
353
+ * - Natural language formats (via Date constructor)
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * // ISO format
358
+ * const date1 = parseDate('2025-07-16');
359
+ * // Result: Date object for July 16, 2025
360
+ *
361
+ * // US format (MM/DD/YYYY)
362
+ * const date2 = parseDate('07/16/2025');
363
+ * // Result: Date object for July 16, 2025
364
+ *
365
+ * // European format (DD/MM/YYYY)
366
+ * const date3 = parseDate('16/07/2025');
367
+ * // Result: Date object for July 16, 2025
368
+ *
369
+ * // Invalid date
370
+ * const invalid = parseDate('not a date');
371
+ * // Result: null
372
+ * ```
373
+ */
374
+ function parseDate(dateStr) {
375
+ // Try various formats
376
+ const formats = [
377
+ /^\d{4}-\d{2}-\d{2}$/, // YYYY-MM-DD
378
+ /^\d{2}\/\d{2}\/\d{4}$/, // MM/DD/YYYY or DD/MM/YYYY
379
+ /^\d{2}-\d{2}-\d{4}$/, // MM-DD-YYYY or DD-MM-YYYY
380
+ ];
381
+ // Direct parsing attempt
382
+ const parsed = new Date(dateStr);
383
+ if (!isNaN(parsed.getTime())) {
384
+ return parsed;
385
+ }
386
+ // Try parsing with format detection
387
+ if (formats[0].test(dateStr)) {
388
+ return new Date(dateStr);
389
+ }
390
+ if (formats[1].test(dateStr) || formats[2].test(dateStr)) {
391
+ const separator = dateStr.includes('/') ? '/' : '-';
392
+ const parts = dateStr.split(separator).map(Number);
393
+ // Assume MM/DD/YYYY for US format if month <= 12
394
+ if (parts[0] <= 12) {
395
+ return new Date(parts[2], parts[0] - 1, parts[1]);
396
+ }
397
+ // Otherwise assume DD/MM/YYYY
398
+ return new Date(parts[2], parts[1] - 1, parts[0]);
399
+ }
400
+ return null;
401
+ }
402
+ //# sourceMappingURL=date-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-helpers.js","sourceRoot":"","sources":["../../src/helpers/date-helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AA4BH,4BAYC;AA0BD,0BAYC;AA2BD,8BAYC;AA4CD,gCA+GC;AA+FD,8BAgCC;AA7YD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,QAAQ,CAAC,IAAmB,EAAE,KAAa;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAErE,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,OAAO,CAAC,IAAmB,EAAE,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,GAAG,CAAC,MAAM,CAAC,CAAC;QAEnD,iDAAiD;QACjD,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACnB,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;QACD,8BAA8B;QAC9B,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @fileoverview Legal Markdown Helpers Module
3
+ *
4
+ * This module provides a comprehensive collection of utility functions for formatting
5
+ * and manipulating dates, numbers, and strings in legal documents. It serves as the
6
+ * central hub for all helper functions used throughout the Legal Markdown system.
7
+ *
8
+ * Features:
9
+ * - Date manipulation and formatting with legal-specific formats
10
+ * - Number formatting with currency, percentage, and word conversion
11
+ * - String manipulation with case conversion and text processing
12
+ * - Template helper registry for use in document processing
13
+ * - Convenient re-exports for easy access to all helper functions
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { formatDate, formatCurrency, capitalize } from './helpers';
18
+ *
19
+ * // Date formatting
20
+ * const date = formatDate(new Date(), 'MMMM Do, YYYY');
21
+ *
22
+ * // Currency formatting
23
+ * const price = formatCurrency(1234.56, 'USD');
24
+ *
25
+ * // String manipulation
26
+ * const title = capitalize('legal document');
27
+ * ```
28
+ */
29
+ export * from './date-helpers';
30
+ export * from './number-helpers';
31
+ export * from './string-helpers';
32
+ import { addYears, addMonths, addDays, formatDate, DateFormats } from './date-helpers';
33
+ import { formatInteger, formatPercent, formatCurrency, formatEuro, formatDollar, formatPound, numberToWords } from './number-helpers';
34
+ import { capitalize, capitalizeWords, upper, lower, titleCase, clean, pluralize } from './string-helpers';
35
+ export { addYears, addMonths, addDays, formatDate, DateFormats, formatInteger, formatPercent, formatCurrency, formatEuro, formatDollar, formatPound, numberToWords, capitalize, capitalizeWords, upper, lower, titleCase, clean, pluralize, };
36
+ import * as numberHelpers from './number-helpers';
37
+ import * as stringHelpers from './string-helpers';
38
+ /**
39
+ * Registry of helper functions for use in template processing
40
+ *
41
+ * This object provides a centralized collection of all helper functions
42
+ * organized by category for easy access during template processing and
43
+ * document generation.
44
+ *
45
+ * @constant {Object} helpers
46
+ * @example
47
+ * ```typescript
48
+ * import { helpers } from './helpers';
49
+ *
50
+ * // Use in template processing
51
+ * const result = helpers.formatDate(new Date(), 'YYYY-MM-DD');
52
+ * const currency = helpers.formatEuro(1234.56);
53
+ * const title = helpers.titleCase('legal document title');
54
+ * ```
55
+ */
56
+ export declare const helpers: {
57
+ addYears: typeof addYears;
58
+ addMonths: typeof addMonths;
59
+ addDays: typeof addDays;
60
+ formatDate: typeof formatDate;
61
+ formatInteger: typeof formatInteger;
62
+ formatPercent: typeof formatPercent;
63
+ formatCurrency: typeof formatCurrency;
64
+ formatEuro: typeof formatEuro;
65
+ formatDollar: typeof formatDollar;
66
+ formatPound: typeof formatPound;
67
+ numberToWords: typeof numberToWords;
68
+ round: typeof numberHelpers.round;
69
+ capitalize: typeof capitalize;
70
+ capitalizeWords: typeof capitalizeWords;
71
+ upper: typeof upper;
72
+ lower: typeof lower;
73
+ titleCase: typeof titleCase;
74
+ kebabCase: typeof stringHelpers.kebabCase;
75
+ snakeCase: typeof stringHelpers.snakeCase;
76
+ camelCase: typeof stringHelpers.camelCase;
77
+ pascalCase: typeof stringHelpers.pascalCase;
78
+ truncate: typeof stringHelpers.truncate;
79
+ clean: typeof clean;
80
+ pluralize: typeof pluralize;
81
+ padStart: typeof stringHelpers.padStart;
82
+ padEnd: typeof stringHelpers.padEnd;
83
+ contains: typeof stringHelpers.contains;
84
+ replaceAll: typeof stringHelpers.replaceAll;
85
+ initials: typeof stringHelpers.initials;
86
+ };
87
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,UAAU,EACV,eAAe,EACf,KAAK,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACV,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAEL,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EAGX,aAAa,EACb,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EAGb,UAAU,EACV,eAAe,EACf,KAAK,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,GACV,CAAC;AAGF,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCnB,CAAC"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Legal Markdown Helpers Module
4
+ *
5
+ * This module provides a comprehensive collection of utility functions for formatting
6
+ * and manipulating dates, numbers, and strings in legal documents. It serves as the
7
+ * central hub for all helper functions used throughout the Legal Markdown system.
8
+ *
9
+ * Features:
10
+ * - Date manipulation and formatting with legal-specific formats
11
+ * - Number formatting with currency, percentage, and word conversion
12
+ * - String manipulation with case conversion and text processing
13
+ * - Template helper registry for use in document processing
14
+ * - Convenient re-exports for easy access to all helper functions
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { formatDate, formatCurrency, capitalize } from './helpers';
19
+ *
20
+ * // Date formatting
21
+ * const date = formatDate(new Date(), 'MMMM Do, YYYY');
22
+ *
23
+ * // Currency formatting
24
+ * const price = formatCurrency(1234.56, 'USD');
25
+ *
26
+ * // String manipulation
27
+ * const title = capitalize('legal document');
28
+ * ```
29
+ */
30
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ var desc = Object.getOwnPropertyDescriptor(m, k);
33
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
34
+ desc = { enumerable: true, get: function() { return m[k]; } };
35
+ }
36
+ Object.defineProperty(o, k2, desc);
37
+ }) : (function(o, m, k, k2) {
38
+ if (k2 === undefined) k2 = k;
39
+ o[k2] = m[k];
40
+ }));
41
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
42
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
43
+ }) : function(o, v) {
44
+ o["default"] = v;
45
+ });
46
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
47
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
48
+ };
49
+ var __importStar = (this && this.__importStar) || (function () {
50
+ var ownKeys = function(o) {
51
+ ownKeys = Object.getOwnPropertyNames || function (o) {
52
+ var ar = [];
53
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
54
+ return ar;
55
+ };
56
+ return ownKeys(o);
57
+ };
58
+ return function (mod) {
59
+ if (mod && mod.__esModule) return mod;
60
+ var result = {};
61
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
62
+ __setModuleDefault(result, mod);
63
+ return result;
64
+ };
65
+ })();
66
+ Object.defineProperty(exports, "__esModule", { value: true });
67
+ exports.helpers = exports.pluralize = exports.clean = exports.titleCase = exports.lower = exports.upper = exports.capitalizeWords = exports.capitalize = exports.numberToWords = exports.formatPound = exports.formatDollar = exports.formatEuro = exports.formatCurrency = exports.formatPercent = exports.formatInteger = exports.DateFormats = exports.formatDate = exports.addDays = exports.addMonths = exports.addYears = void 0;
68
+ __exportStar(require("./date-helpers"), exports);
69
+ __exportStar(require("./number-helpers"), exports);
70
+ __exportStar(require("./string-helpers"), exports);
71
+ // Individual imports for re-export
72
+ const date_helpers_1 = require("./date-helpers");
73
+ Object.defineProperty(exports, "addYears", { enumerable: true, get: function () { return date_helpers_1.addYears; } });
74
+ Object.defineProperty(exports, "addMonths", { enumerable: true, get: function () { return date_helpers_1.addMonths; } });
75
+ Object.defineProperty(exports, "addDays", { enumerable: true, get: function () { return date_helpers_1.addDays; } });
76
+ Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return date_helpers_1.formatDate; } });
77
+ Object.defineProperty(exports, "DateFormats", { enumerable: true, get: function () { return date_helpers_1.DateFormats; } });
78
+ const number_helpers_1 = require("./number-helpers");
79
+ Object.defineProperty(exports, "formatInteger", { enumerable: true, get: function () { return number_helpers_1.formatInteger; } });
80
+ Object.defineProperty(exports, "formatPercent", { enumerable: true, get: function () { return number_helpers_1.formatPercent; } });
81
+ Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: function () { return number_helpers_1.formatCurrency; } });
82
+ Object.defineProperty(exports, "formatEuro", { enumerable: true, get: function () { return number_helpers_1.formatEuro; } });
83
+ Object.defineProperty(exports, "formatDollar", { enumerable: true, get: function () { return number_helpers_1.formatDollar; } });
84
+ Object.defineProperty(exports, "formatPound", { enumerable: true, get: function () { return number_helpers_1.formatPound; } });
85
+ Object.defineProperty(exports, "numberToWords", { enumerable: true, get: function () { return number_helpers_1.numberToWords; } });
86
+ const string_helpers_1 = require("./string-helpers");
87
+ Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return string_helpers_1.capitalize; } });
88
+ Object.defineProperty(exports, "capitalizeWords", { enumerable: true, get: function () { return string_helpers_1.capitalizeWords; } });
89
+ Object.defineProperty(exports, "upper", { enumerable: true, get: function () { return string_helpers_1.upper; } });
90
+ Object.defineProperty(exports, "lower", { enumerable: true, get: function () { return string_helpers_1.lower; } });
91
+ Object.defineProperty(exports, "titleCase", { enumerable: true, get: function () { return string_helpers_1.titleCase; } });
92
+ Object.defineProperty(exports, "clean", { enumerable: true, get: function () { return string_helpers_1.clean; } });
93
+ Object.defineProperty(exports, "pluralize", { enumerable: true, get: function () { return string_helpers_1.pluralize; } });
94
+ const dateHelpers = __importStar(require("./date-helpers"));
95
+ const numberHelpers = __importStar(require("./number-helpers"));
96
+ const stringHelpers = __importStar(require("./string-helpers"));
97
+ /**
98
+ * Registry of helper functions for use in template processing
99
+ *
100
+ * This object provides a centralized collection of all helper functions
101
+ * organized by category for easy access during template processing and
102
+ * document generation.
103
+ *
104
+ * @constant {Object} helpers
105
+ * @example
106
+ * ```typescript
107
+ * import { helpers } from './helpers';
108
+ *
109
+ * // Use in template processing
110
+ * const result = helpers.formatDate(new Date(), 'YYYY-MM-DD');
111
+ * const currency = helpers.formatEuro(1234.56);
112
+ * const title = helpers.titleCase('legal document title');
113
+ * ```
114
+ */
115
+ exports.helpers = {
116
+ // Date helpers
117
+ addYears: dateHelpers.addYears,
118
+ addMonths: dateHelpers.addMonths,
119
+ addDays: dateHelpers.addDays,
120
+ formatDate: dateHelpers.formatDate,
121
+ // Number helpers
122
+ formatInteger: numberHelpers.formatInteger,
123
+ formatPercent: numberHelpers.formatPercent,
124
+ formatCurrency: numberHelpers.formatCurrency,
125
+ formatEuro: numberHelpers.formatEuro,
126
+ formatDollar: numberHelpers.formatDollar,
127
+ formatPound: numberHelpers.formatPound,
128
+ numberToWords: numberHelpers.numberToWords,
129
+ round: numberHelpers.round,
130
+ // String helpers
131
+ capitalize: stringHelpers.capitalize,
132
+ capitalizeWords: stringHelpers.capitalizeWords,
133
+ upper: stringHelpers.upper,
134
+ lower: stringHelpers.lower,
135
+ titleCase: stringHelpers.titleCase,
136
+ kebabCase: stringHelpers.kebabCase,
137
+ snakeCase: stringHelpers.snakeCase,
138
+ camelCase: stringHelpers.camelCase,
139
+ pascalCase: stringHelpers.pascalCase,
140
+ truncate: stringHelpers.truncate,
141
+ clean: stringHelpers.clean,
142
+ pluralize: stringHelpers.pluralize,
143
+ padStart: stringHelpers.padStart,
144
+ padEnd: stringHelpers.padEnd,
145
+ contains: stringHelpers.contains,
146
+ replaceAll: stringHelpers.replaceAll,
147
+ initials: stringHelpers.initials,
148
+ };
149
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,mDAAiC;AACjC,mDAAiC;AAEjC,mCAAmC;AACnC,iDAAuF;AAyBrF,yFAzBO,uBAAQ,OAyBP;AACR,0FA1BiB,wBAAS,OA0BjB;AACT,wFA3B4B,sBAAO,OA2B5B;AACP,2FA5BqC,yBAAU,OA4BrC;AACV,4FA7BiD,0BAAW,OA6BjD;AA3Bb,qDAQ0B;AAsBxB,8FA7BA,8BAAa,OA6BA;AACb,8FA7BA,8BAAa,OA6BA;AACb,+FA7BA,+BAAc,OA6BA;AACd,2FA7BA,2BAAU,OA6BA;AACV,6FA7BA,6BAAY,OA6BA;AACZ,4FA7BA,4BAAW,OA6BA;AACX,8FA7BA,8BAAa,OA6BA;AA1Bf,qDAQ0B;AAqBxB,2FA5BA,2BAAU,OA4BA;AACV,gGA5BA,gCAAe,OA4BA;AACf,sFA5BA,sBAAK,OA4B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