legal-markdown-js 2.2.0 → 2.4.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.
- package/README.md +5 -5
- package/dist/core/processors/mixin-processor.d.ts.map +1 -1
- package/dist/core/processors/mixin-processor.js +5 -1
- package/dist/core/processors/mixin-processor.js.map +1 -1
- package/dist/core/processors/reference-processor.d.ts +40 -86
- package/dist/core/processors/reference-processor.d.ts.map +1 -1
- package/dist/core/processors/reference-processor.js +172 -215
- package/dist/core/processors/reference-processor.js.map +1 -1
- package/dist/extensions/template-loops.js +21 -10
- package/dist/extensions/template-loops.js.map +1 -1
- package/dist/legal-markdown.umd.min.js +1 -1
- package/dist/legal-markdown.umd.min.js.map +1 -1
- package/dist/styles/default.css +407 -83
- package/dist/web/legal-markdown.umd.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
> feature parity.
|
|
6
6
|
|
|
7
7
|
Process markdown with YAML front matter, conditional clauses
|
|
8
|
-
`[text]{condition}`, cross-references `|
|
|
9
|
-
generate professional PDFs ready to be shared.
|
|
8
|
+
`[text]{condition}`, cross-references `|reference|`, mixins `{{variable}}`,
|
|
9
|
+
imports `@import`, and generate professional PDFs ready to be shared.
|
|
10
10
|
|
|
11
11
|

|
|
12
12
|
|
|
@@ -84,8 +84,7 @@ All original Legal Markdown features are fully implemented:
|
|
|
84
84
|
`lll.`)
|
|
85
85
|
- **Optional Clauses**: Boolean, equality, and logical operations
|
|
86
86
|
(`[text]{condition}`)
|
|
87
|
-
- **Cross-References**:
|
|
88
|
-
(`|reference|`)
|
|
87
|
+
- **Cross-References**: Internal section references using (`|reference|`) syntax
|
|
89
88
|
- **Partial Imports**: File inclusion with path resolution (`@import`)
|
|
90
89
|
- **Metadata Export**: YAML and JSON export with custom paths
|
|
91
90
|
|
|
@@ -93,7 +92,8 @@ All original Legal Markdown features are fully implemented:
|
|
|
93
92
|
|
|
94
93
|
Additional features available only in the Node.js version:
|
|
95
94
|
|
|
96
|
-
- **Mixins System**: Template substitution with `{{variable}}`
|
|
95
|
+
- **Mixins System**: Template substitution and helpers with `{{variable}}`
|
|
96
|
+
syntax
|
|
97
97
|
- **PDF Generation**: Professional PDF output with styling and field
|
|
98
98
|
highlighting
|
|
99
99
|
- **HTML Generation**: Custom HTML output with CSS support
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixin-processor.d.ts","sourceRoot":"","sources":["../../../src/core/processors/mixin-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAmB9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,OAAO,GAAE,oBAAyB,GACjC,MAAM,
|
|
1
|
+
{"version":3,"file":"mixin-processor.d.ts","sourceRoot":"","sources":["../../../src/core/processors/mixin-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAmB9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,OAAO,GAAE,oBAAyB,GACjC,MAAM,CA0UR"}
|
|
@@ -134,6 +134,10 @@ function processMixins(content, metadata, options = {}) {
|
|
|
134
134
|
* ```
|
|
135
135
|
*/
|
|
136
136
|
function resolvePath(obj, path) {
|
|
137
|
+
// Handle special case for current item in template loops
|
|
138
|
+
if (path === '.') {
|
|
139
|
+
return obj?.['.'];
|
|
140
|
+
}
|
|
137
141
|
return path.split('.').reduce((current, part) => {
|
|
138
142
|
// Handle array indices like parties.0.name
|
|
139
143
|
const match = part.match(/^(\w+)\[(\d+)\]$/);
|
|
@@ -392,7 +396,7 @@ function processMixins(content, metadata, options = {}) {
|
|
|
392
396
|
});
|
|
393
397
|
}
|
|
394
398
|
// First process template loops, then regular mixins
|
|
395
|
-
const loopProcessedContent = (0, template_loops_1.processTemplateLoops)(content, metadata, undefined, options.enableFieldTrackingInMarkdown);
|
|
399
|
+
const loopProcessedContent = (0, template_loops_1.processTemplateLoops)(content, metadata, undefined, options.enableFieldTrackingInMarkdown || false);
|
|
396
400
|
return replaceMixins(loopProcessedContent);
|
|
397
401
|
}
|
|
398
402
|
//# sourceMappingURL=mixin-processor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixin-processor.js","sourceRoot":"","sources":["../../../src/core/processors/mixin-processor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;AAiEH,
|
|
1
|
+
{"version":3,"file":"mixin-processor.js","sourceRoot":"","sources":["../../../src/core/processors/mixin-processor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;AAiEH,sCA8UC;AA5YD,gEAA4D;AAC5D,2CAAwC;AACxC,oEAAuE;AAEvE;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3B,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AC1C,OAAO,2CAA2C,mBAAmB,CAAC,UAAU,CAAC,OAAO,UAAU,WAAW,CAAC;gBAChH,CAAC;gBACD,OAAO,KAAK,UAAU,IAAI,CAAC;YAC7B,CAAC;YAED,qBAAqB;YACrB,4BAAY,CAAC,UAAU,CAAC,UAAU,EAAE;gBAClC,KAAK,EAAE,KAAK;gBACZ,QAAQ,EAAE,KAAK;aAChB,CAAC,CAAC;YAEH,0BAA0B;YAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAElC,2DAA2D;YAC3D,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;gBACnC,MAAM,YAAY,GAAG,aAAa,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;gBAC3D,IAAI,OAAO,CAAC,6BAA6B,EAAE,CAAC;oBAC1C,OAAO,4CAA4C,mBAAmB,CAAC,UAAU,CAAC,KAAK,YAAY,SAAS,CAAC;gBAC/G,CAAC;gBACD,OAAO,YAAY,CAAC;YACtB,CAAC;YAED,IAAI,OAAO,CAAC,6BAA6B,EAAE,CAAC;gBAC1C,OAAO,4CAA4C,mBAAmB,CAAC,UAAU,CAAC,KAAK,WAAW,SAAS,CAAC;YAC9G,CAAC;YACD,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oDAAoD;IACpD,MAAM,oBAAoB,GAAG,IAAA,qCAAoB,EAC/C,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,CAAC,6BAA6B,IAAI,KAAK,CAC/C,CAAC;IACF,OAAO,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,115 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Cross-Reference Processing Module for Legal Markdown Documents
|
|
3
3
|
*
|
|
4
|
-
* This module provides functionality to process cross-references in Legal Markdown
|
|
5
|
-
* documents,
|
|
6
|
-
*
|
|
7
|
-
* formatting, and nested metadata access through dot notation.
|
|
4
|
+
* This module provides functionality to process internal cross-references in Legal Markdown
|
|
5
|
+
* documents, allowing sections to reference other sections by their keys.
|
|
6
|
+
* Based on the original Ruby Legal Markdown specification.
|
|
8
7
|
*
|
|
9
8
|
* Features:
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
15
|
-
* - Fallback to original reference if value not found
|
|
16
|
-
* - Integration with date-processor for date handling
|
|
9
|
+
* - Internal cross-reference syntax: |reference_key|
|
|
10
|
+
* - Automatic section numbering and reference resolution
|
|
11
|
+
* - Reference capture from headers with |key| syntax
|
|
12
|
+
* - Section reference replacement throughout the document
|
|
13
|
+
* - Compatible with legal document numbering (l., ll., lll.)
|
|
17
14
|
*
|
|
18
15
|
* @example
|
|
19
16
|
* ```typescript
|
|
20
17
|
* import { processCrossReferences } from './reference-processor';
|
|
21
18
|
*
|
|
22
19
|
* const content = `
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `;
|
|
20
|
+
* l. **Definitions** |definitions|
|
|
21
|
+
*
|
|
22
|
+
* Terms defined in |definitions| apply throughout this agreement.
|
|
27
23
|
*
|
|
28
|
-
*
|
|
29
|
-
* client: { name: "Acme Corp" },
|
|
30
|
-
* provider: { name: "Service Ltd" },
|
|
31
|
-
* contract: {
|
|
32
|
-
* amount: 25000,
|
|
33
|
-
* due_date: new Date("2024-12-31")
|
|
34
|
-
* },
|
|
35
|
-
* payment_currency: "USD"
|
|
36
|
-
* };
|
|
24
|
+
* l. **Payment Terms** |payment|
|
|
37
25
|
*
|
|
38
|
-
*
|
|
26
|
+
* As outlined in |payment|, payment is due within 30 days.
|
|
27
|
+
* Reference to |definitions| for term meanings.
|
|
28
|
+
* `;
|
|
29
|
+
*
|
|
30
|
+
* const processed = processCrossReferences(content, {});
|
|
39
31
|
* console.log(processed);
|
|
40
32
|
* // Output:
|
|
41
|
-
* //
|
|
42
|
-
* //
|
|
43
|
-
* //
|
|
33
|
+
* // Article 1. **Definitions**
|
|
34
|
+
* //
|
|
35
|
+
* // Terms defined in Article 1 apply throughout this agreement.
|
|
36
|
+
* //
|
|
37
|
+
* // Article 2. **Payment Terms**
|
|
38
|
+
* //
|
|
39
|
+
* // As outlined in Article 2, payment is due within 30 days.
|
|
40
|
+
* // Reference to Article 1 for term meanings.
|
|
44
41
|
* ```
|
|
45
42
|
*/
|
|
46
43
|
/**
|
|
47
|
-
* Processes cross-references in a
|
|
44
|
+
* Processes internal cross-references in a Legal Markdown document
|
|
48
45
|
*
|
|
49
|
-
* This
|
|
50
|
-
*
|
|
51
|
-
*
|
|
46
|
+
* This function implements a hybrid approach:
|
|
47
|
+
* 1. First tries to resolve |key| as internal section references (Ruby spec)
|
|
48
|
+
* 2. Falls back to metadata values for backward compatibility
|
|
52
49
|
*
|
|
53
50
|
* @param {string} content - The document content containing cross-references
|
|
54
|
-
* @param {Record<string, any>} metadata - Document metadata
|
|
55
|
-
* @returns {string} Processed content with references
|
|
51
|
+
* @param {Record<string, any>} metadata - Document metadata (used for level formatting and fallback)
|
|
52
|
+
* @returns {string} Processed content with internal references resolved
|
|
56
53
|
* @example
|
|
57
54
|
* ```typescript
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* const metadata = {
|
|
61
|
-
* payment: {
|
|
62
|
-
* amount: 1500,
|
|
63
|
-
* date: new Date("2024-03-15")
|
|
64
|
-
* },
|
|
65
|
-
* payment_currency: "EUR"
|
|
66
|
-
* };
|
|
67
|
-
*
|
|
68
|
-
* const result = processCrossReferences(content, metadata);
|
|
69
|
-
* // Output: "Payment due: €1,500.00 on 2024-03-15"
|
|
55
|
+
* const content = `
|
|
56
|
+
* l. **Contract Terms** |terms|
|
|
70
57
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* client: {
|
|
75
|
-
* contact: {
|
|
76
|
-
* email: "info@client.com",
|
|
77
|
-
* phone: "+1-555-0123"
|
|
78
|
-
* }
|
|
79
|
-
* }
|
|
80
|
-
* };
|
|
58
|
+
* As specified in |terms|, this agreement is binding.
|
|
59
|
+
* Reference to |client_name| from metadata.
|
|
60
|
+
* `;
|
|
81
61
|
*
|
|
82
|
-
* const
|
|
83
|
-
*
|
|
62
|
+
* const metadata = { client_name: "ACME Corp" };
|
|
63
|
+
* const result = processCrossReferences(content, metadata);
|
|
64
|
+
* // |terms| -> "Article 1." (internal reference)
|
|
65
|
+
* // |client_name| -> "ACME Corp" (metadata fallback)
|
|
84
66
|
* ```
|
|
85
67
|
*/
|
|
86
68
|
export declare function processCrossReferences(content: string, metadata: Record<string, any>): string;
|
|
87
|
-
/**
|
|
88
|
-
* Processes special reference formats like dates and currency amounts
|
|
89
|
-
*
|
|
90
|
-
* Applies appropriate formatting to reference values based on their type and
|
|
91
|
-
* optional format specifiers. Handles dates, currency amounts, and falls back
|
|
92
|
-
* to string conversion for other types.
|
|
93
|
-
*
|
|
94
|
-
* @param {any} value - The reference value to format
|
|
95
|
-
* @param {string} [format] - Optional format specifier (e.g., "currency:USD:en-US")
|
|
96
|
-
* @returns {string} Formatted value as string
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* // Date formatting
|
|
100
|
-
* const date = new Date("2024-03-15");
|
|
101
|
-
* console.log(formatReferenceValue(date)); // "2024-03-15"
|
|
102
|
-
* console.log(formatReferenceValue(date, "long")); // "March 15, 2024"
|
|
103
|
-
* console.log(formatReferenceValue(date, "short")); // "3/15/2024"
|
|
104
|
-
*
|
|
105
|
-
* // Currency formatting
|
|
106
|
-
* console.log(formatReferenceValue(1500, "currency:USD")); // "$1,500.00"
|
|
107
|
-
* console.log(formatReferenceValue(1500, "currency:EUR:de-DE")); // "1.500,00 €"
|
|
108
|
-
*
|
|
109
|
-
* // Default string conversion
|
|
110
|
-
* console.log(formatReferenceValue("Hello World")); // "Hello World"
|
|
111
|
-
* console.log(formatReferenceValue(12345)); // "12345"
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
export declare function formatReferenceValue(value: any, format?: string): string;
|
|
115
69
|
//# sourceMappingURL=reference-processor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference-processor.d.ts","sourceRoot":"","sources":["../../../src/core/processors/reference-processor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"reference-processor.d.ts","sourceRoot":"","sources":["../../../src/core/processors/reference-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAWH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAM7F"}
|