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.
- package/LICENSE +21 -0
- package/README.md +168 -0
- package/dist/browser.d.ts +87 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +157 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli/index.d.ts +34 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +221 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/service.d.ts +128 -0
- package/dist/cli/service.d.ts.map +1 -0
- package/dist/cli/service.js +284 -0
- package/dist/cli/service.js.map +1 -0
- package/dist/constants/index.d.ts +229 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +232 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/core/exporters/metadata-exporter.d.ts +104 -0
- package/dist/core/exporters/metadata-exporter.d.ts.map +1 -0
- package/dist/core/exporters/metadata-exporter.js +201 -0
- package/dist/core/exporters/metadata-exporter.js.map +1 -0
- package/dist/core/index.d.ts +40 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +56 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/parsers/yaml-parser.d.ts +149 -0
- package/dist/core/parsers/yaml-parser.d.ts.map +1 -0
- package/dist/core/parsers/yaml-parser.js +321 -0
- package/dist/core/parsers/yaml-parser.js.map +1 -0
- package/dist/core/processors/clause-processor.d.ts +74 -0
- package/dist/core/processors/clause-processor.d.ts.map +1 -0
- package/dist/core/processors/clause-processor.js +213 -0
- package/dist/core/processors/clause-processor.js.map +1 -0
- package/dist/core/processors/date-processor.d.ts +90 -0
- package/dist/core/processors/date-processor.d.ts.map +1 -0
- package/dist/core/processors/date-processor.js +336 -0
- package/dist/core/processors/date-processor.js.map +1 -0
- package/dist/core/processors/header-processor.d.ts +104 -0
- package/dist/core/processors/header-processor.d.ts.map +1 -0
- package/dist/core/processors/header-processor.js +585 -0
- package/dist/core/processors/header-processor.js.map +1 -0
- package/dist/core/processors/import-processor.d.ts +116 -0
- package/dist/core/processors/import-processor.d.ts.map +1 -0
- package/dist/core/processors/import-processor.js +236 -0
- package/dist/core/processors/import-processor.js.map +1 -0
- package/dist/core/processors/mixin-processor.d.ts +93 -0
- package/dist/core/processors/mixin-processor.d.ts.map +1 -0
- package/dist/core/processors/mixin-processor.js +378 -0
- package/dist/core/processors/mixin-processor.js.map +1 -0
- package/dist/core/processors/reference-processor.d.ts +115 -0
- package/dist/core/processors/reference-processor.d.ts.map +1 -0
- package/dist/core/processors/reference-processor.js +273 -0
- package/dist/core/processors/reference-processor.js.map +1 -0
- package/dist/errors/index.d.ts +234 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +267 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/extensions/batch-processor.d.ts +197 -0
- package/dist/extensions/batch-processor.d.ts.map +1 -0
- package/dist/extensions/batch-processor.js +392 -0
- package/dist/extensions/batch-processor.js.map +1 -0
- package/dist/extensions/formatters/index.d.ts +99 -0
- package/dist/extensions/formatters/index.d.ts.map +1 -0
- package/dist/extensions/formatters/index.js +128 -0
- package/dist/extensions/formatters/index.js.map +1 -0
- package/dist/extensions/index.d.ts +53 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +71 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/latex-parser.d.ts +111 -0
- package/dist/extensions/latex-parser.d.ts.map +1 -0
- package/dist/extensions/latex-parser.js +563 -0
- package/dist/extensions/latex-parser.js.map +1 -0
- package/dist/extensions/rst-parser.d.ts +112 -0
- package/dist/extensions/rst-parser.d.ts.map +1 -0
- package/dist/extensions/rst-parser.js +268 -0
- package/dist/extensions/rst-parser.js.map +1 -0
- package/dist/extensions/template-loops.d.ts +61 -0
- package/dist/extensions/template-loops.d.ts.map +1 -0
- package/dist/extensions/template-loops.js +418 -0
- package/dist/extensions/template-loops.js.map +1 -0
- package/dist/extensions/utilities/index.d.ts +114 -0
- package/dist/extensions/utilities/index.d.ts.map +1 -0
- package/dist/extensions/utilities/index.js +137 -0
- package/dist/extensions/utilities/index.js.map +1 -0
- package/dist/extensions/validators/index.d.ts +65 -0
- package/dist/extensions/validators/index.d.ts.map +1 -0
- package/dist/extensions/validators/index.js +88 -0
- package/dist/extensions/validators/index.js.map +1 -0
- package/dist/generators/html-generator.d.ts +184 -0
- package/dist/generators/html-generator.d.ts.map +1 -0
- package/dist/generators/html-generator.js +361 -0
- package/dist/generators/html-generator.js.map +1 -0
- package/dist/generators/pdf-generator.d.ts +165 -0
- package/dist/generators/pdf-generator.d.ts.map +1 -0
- package/dist/generators/pdf-generator.js +275 -0
- package/dist/generators/pdf-generator.js.map +1 -0
- package/dist/helpers/date-helpers.d.ts +216 -0
- package/dist/helpers/date-helpers.d.ts.map +1 -0
- package/dist/helpers/date-helpers.js +402 -0
- package/dist/helpers/date-helpers.js.map +1 -0
- package/dist/helpers/index.d.ts +87 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +149 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/number-helpers.d.ts +269 -0
- package/dist/helpers/number-helpers.d.ts.map +1 -0
- package/dist/helpers/number-helpers.js +406 -0
- package/dist/helpers/number-helpers.js.map +1 -0
- package/dist/helpers/string-helpers.d.ts +391 -0
- package/dist/helpers/string-helpers.d.ts.map +1 -0
- package/dist/helpers/string-helpers.js +549 -0
- package/dist/helpers/string-helpers.js.map +1 -0
- package/dist/index.d.ts +229 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +384 -0
- package/dist/index.js.map +1 -0
- package/dist/legal-markdown.umd.min.js +2 -0
- package/dist/legal-markdown.umd.min.js.LICENSE.txt +14 -0
- package/dist/legal-markdown.umd.min.js.map +1 -0
- package/dist/lib/index.d.ts +150 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +265 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/parsers/content-detector.d.ts +131 -0
- package/dist/parsers/content-detector.d.ts.map +1 -0
- package/dist/parsers/content-detector.js +220 -0
- package/dist/parsers/content-detector.js.map +1 -0
- package/dist/parsers/fallback-parsers.d.ts +14 -0
- package/dist/parsers/fallback-parsers.d.ts.map +1 -0
- package/dist/parsers/fallback-parsers.js +188 -0
- package/dist/parsers/fallback-parsers.js.map +1 -0
- package/dist/parsers/implementations/pandoc-native.d.ts +13 -0
- package/dist/parsers/implementations/pandoc-native.d.ts.map +1 -0
- package/dist/parsers/implementations/pandoc-native.js +63 -0
- package/dist/parsers/implementations/pandoc-native.js.map +1 -0
- package/dist/parsers/implementations/pandoc-wasm.d.ts +14 -0
- package/dist/parsers/implementations/pandoc-wasm.d.ts.map +1 -0
- package/dist/parsers/implementations/pandoc-wasm.js +64 -0
- package/dist/parsers/implementations/pandoc-wasm.js.map +1 -0
- package/dist/parsers/pandoc-factory.d.ts +97 -0
- package/dist/parsers/pandoc-factory.d.ts.map +1 -0
- package/dist/parsers/pandoc-factory.js +146 -0
- package/dist/parsers/pandoc-factory.js.map +1 -0
- package/dist/parsers/pandoc-loader.d.ts +24 -0
- package/dist/parsers/pandoc-loader.d.ts.map +1 -0
- package/dist/parsers/pandoc-loader.js +124 -0
- package/dist/parsers/pandoc-loader.js.map +1 -0
- package/dist/parsers/pandoc-parser.d.ts +27 -0
- package/dist/parsers/pandoc-parser.d.ts.map +1 -0
- package/dist/parsers/pandoc-parser.js +3 -0
- package/dist/parsers/pandoc-parser.js.map +1 -0
- package/dist/styles/default.css +125 -0
- package/dist/styles/headers.css +146 -0
- package/dist/styles/highlight.css +171 -0
- package/dist/tracking/field-tracker.d.ts +206 -0
- package/dist/tracking/field-tracker.d.ts.map +1 -0
- package/dist/tracking/field-tracker.js +247 -0
- package/dist/tracking/field-tracker.js.map +1 -0
- package/dist/types.d.ts +186 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +33 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/logger.d.ts +107 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +122 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/web/bundle-standalone.js +28 -0
- package/dist/web/bundle.js +17 -0
- package/dist/web/index.html +1465 -0
- package/dist/web/legal-markdown.umd.min.js +2 -0
- package/dist/web/standalone.html +390 -0
- package/dist/web/styles.css +874 -0
- package/package.json +118 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Legal MD Wizard Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Legal Markdown JS
|
|
2
|
+
|
|
3
|
+
A Node.js implementation of
|
|
4
|
+
[LegalMarkdown](https://github.com/compleatang/legal-markdown) for processing
|
|
5
|
+
legal documents with structured markdown and YAML front matter.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Goals](#goals)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Quick Start](#quick-start)
|
|
12
|
+
- [Key Features](#key-features)
|
|
13
|
+
- [Documentation](#documentation)
|
|
14
|
+
- [Testing](#testing)
|
|
15
|
+
- [Contributing](#contributing)
|
|
16
|
+
- [License](#license)
|
|
17
|
+
|
|
18
|
+
## Goals
|
|
19
|
+
|
|
20
|
+
- **Core Parity**: 1:1 compatibility with the original Ruby legal-markdown tool
|
|
21
|
+
- **Node.js Extensions**: Additional functionality leveraging the Node.js
|
|
22
|
+
ecosystem
|
|
23
|
+
- **Type Safety**: Full TypeScript implementation with comprehensive type
|
|
24
|
+
definitions
|
|
25
|
+
- **Modern Tooling**: Built with modern development practices and tooling
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install legal-markdown-js
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
### Command Line Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Basic document processing
|
|
39
|
+
legal-md input.md output.md
|
|
40
|
+
|
|
41
|
+
# Generate PDF with highlighting
|
|
42
|
+
legal-md document.md --pdf --highlight
|
|
43
|
+
|
|
44
|
+
# Process with custom CSS
|
|
45
|
+
legal-md document.md --html --css styles.css
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Programmatic Usage
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { processLegalMarkdown } from 'legal-markdown-js';
|
|
52
|
+
|
|
53
|
+
const result = processLegalMarkdown(content, {
|
|
54
|
+
basePath: './documents',
|
|
55
|
+
exportMetadata: true,
|
|
56
|
+
exportFormat: 'json',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
console.log(result.content);
|
|
60
|
+
console.log(result.metadata);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Key Features
|
|
64
|
+
|
|
65
|
+
### Core Compatibility
|
|
66
|
+
|
|
67
|
+
All original Legal Markdown features are fully implemented:
|
|
68
|
+
|
|
69
|
+
- **File Formats**: Markdown, ASCII, reStructuredText, LaTeX
|
|
70
|
+
- **YAML Front Matter**: Complete parsing with all standard fields
|
|
71
|
+
- **Headers & Numbering**: Full hierarchical numbering system (`l.`, `ll.`,
|
|
72
|
+
`lll.`)
|
|
73
|
+
- **Optional Clauses**: Boolean, equality, and logical operations
|
|
74
|
+
(`[text]{condition}`)
|
|
75
|
+
- **Cross-References**: All reference types including special date handling
|
|
76
|
+
(`|reference|`)
|
|
77
|
+
- **Partial Imports**: File inclusion with path resolution (`@import`)
|
|
78
|
+
- **Metadata Export**: YAML and JSON export with custom paths
|
|
79
|
+
|
|
80
|
+
### Node.js Enhancements
|
|
81
|
+
|
|
82
|
+
Additional features available only in the Node.js version:
|
|
83
|
+
|
|
84
|
+
- **Mixins System**: Template substitution with `{{variable}}` syntax
|
|
85
|
+
- **PDF Generation**: Professional PDF output with styling and field
|
|
86
|
+
highlighting
|
|
87
|
+
- **HTML Generation**: Custom HTML output with CSS support
|
|
88
|
+
- **Template Loops**: Array iteration with `[#items]...[/items]` syntax
|
|
89
|
+
- **Helper Functions**: Date, number, and string formatting helpers
|
|
90
|
+
- **Batch Processing**: Multi-file processing with concurrency control
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
### User Documentation
|
|
95
|
+
|
|
96
|
+
- **[Getting Started](docs/GETTING-STARTED.md)** - Installation and setup guide
|
|
97
|
+
- **[CLI Reference](docs/CLI-REFERENCE.md)** - Complete command-line interface
|
|
98
|
+
documentation
|
|
99
|
+
- **[Features Guide](docs/FEATURES-GUIDE.md)** - All features, helpers, and
|
|
100
|
+
advanced usage
|
|
101
|
+
- **[Headers & Numbering](docs/HEADERS-NUMBERING.md)** - Hierarchical numbering
|
|
102
|
+
system guide
|
|
103
|
+
- **[CSS Classes Reference](docs/CSS-CLASSES.md)** - CSS classes for styling and
|
|
104
|
+
document review
|
|
105
|
+
- **[Compatibility](docs/COMPATIBILITY.md)** - Ruby version compatibility
|
|
106
|
+
tracking
|
|
107
|
+
|
|
108
|
+
### Developer Documentation
|
|
109
|
+
|
|
110
|
+
- **[Architecture](docs/ARCHITECTURE.md)** - Complete system architecture and design patterns
|
|
111
|
+
- **[Contributing Guide](docs/CONTRIBUTING.md)** - Development workflow, standards, and contribution guidelines
|
|
112
|
+
- **[Helper Functions](docs/HELPERS.md)** - Complete reference for template helpers and functions
|
|
113
|
+
- **[Development Guide](docs/DEVELOPMENT-GUIDE.md)** - Complete developer setup
|
|
114
|
+
and workflow
|
|
115
|
+
- **[Release Process](docs/RELEASE-PROCESS.md)** - Versioning and release
|
|
116
|
+
procedures
|
|
117
|
+
- **[Scripts Reference](docs/SCRIPTS-REFERENCE.md)** - Available npm scripts and
|
|
118
|
+
commands
|
|
119
|
+
- **[API Documentation](docs/api/)** - Auto-generated TypeScript API docs
|
|
120
|
+
|
|
121
|
+
## Testing
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Run all tests
|
|
125
|
+
npm test
|
|
126
|
+
|
|
127
|
+
# Run specific test types
|
|
128
|
+
npm run test:unit
|
|
129
|
+
npm run test:integration
|
|
130
|
+
npm run test:e2e
|
|
131
|
+
|
|
132
|
+
# Run with coverage
|
|
133
|
+
npm run test:coverage
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The project includes comprehensive testing with 495 tests across 29 test suites:
|
|
137
|
+
|
|
138
|
+
- **Unit Tests**: Test individual components in isolation
|
|
139
|
+
- **Integration Tests**: Test complete workflows and feature combinations
|
|
140
|
+
- **E2E Tests**: Test CLI interface and full application behavior
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
We welcome contributions! Please see our
|
|
145
|
+
[Contributing Guide](docs/CONTRIBUTING.md) for:
|
|
146
|
+
|
|
147
|
+
- Development setup and workflow
|
|
148
|
+
- Coding standards and best practices
|
|
149
|
+
- Testing requirements
|
|
150
|
+
- Pull request process
|
|
151
|
+
|
|
152
|
+
### Quick Start for Contributors
|
|
153
|
+
|
|
154
|
+
1. Fork the repository
|
|
155
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
156
|
+
3. Follow the development guidelines
|
|
157
|
+
4. Run the test suite (`npm test`)
|
|
158
|
+
5. Submit a Pull Request
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
163
|
+
|
|
164
|
+
## Acknowledgments
|
|
165
|
+
|
|
166
|
+
- Original [LegalMarkdown](https://github.com/compleatang/legal-markdown)
|
|
167
|
+
project by Casey Kuhlman
|
|
168
|
+
- The legal tech community for inspiration and feedback
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Browser-Specific Entry Point for Legal Markdown Processing
|
|
3
|
+
*
|
|
4
|
+
* This module provides a browser-compatible version of the Legal Markdown
|
|
5
|
+
* processing library that excludes Node.js-specific features like file system
|
|
6
|
+
* operations and PDF generation. It's optimized for web environments and
|
|
7
|
+
* client-side processing.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - YAML front matter parsing and metadata extraction
|
|
11
|
+
* - Cross-reference processing and resolution
|
|
12
|
+
* - Optional clause conditional rendering
|
|
13
|
+
* - Mixin system for reusable content blocks
|
|
14
|
+
* - Header numbering and formatting
|
|
15
|
+
* - Field tracking for document highlighting
|
|
16
|
+
* - RST and LaTeX preprocessing support
|
|
17
|
+
* - UMD build compatibility for script tag usage
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { processLegalMarkdown } from 'legal-markdown-js/browser';
|
|
22
|
+
*
|
|
23
|
+
* // Browser-compatible document processing
|
|
24
|
+
* const result = processLegalMarkdown(content, {
|
|
25
|
+
* enableFieldTracking: true,
|
|
26
|
+
* noClauses: false
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* console.log(result.content); // Processed markdown
|
|
30
|
+
* console.log(result.metadata); // YAML front matter
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
import { fieldTracker } from './tracking/field-tracker';
|
|
34
|
+
import { LegalMarkdownOptions } from '@types';
|
|
35
|
+
/**
|
|
36
|
+
* Browser-compatible version of Legal Markdown processing
|
|
37
|
+
*
|
|
38
|
+
* This function provides the core Legal Markdown processing functionality
|
|
39
|
+
* optimized for browser environments. It excludes Node.js-specific features
|
|
40
|
+
* like file system operations while maintaining full compatibility with
|
|
41
|
+
* YAML parsing, content processing, and field tracking.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} content - The raw Legal Markdown content to process
|
|
44
|
+
* @param {Omit<LegalMarkdownOptions, 'basePath' | 'exportPath'>} [options={}] - Browser-compatible configuration options
|
|
45
|
+
* @returns {Object} Processing result containing processed content, metadata, and reports
|
|
46
|
+
* @returns {string} returns.content - The processed document content
|
|
47
|
+
* @returns {Record<string, any>} [returns.metadata] - Extracted YAML metadata
|
|
48
|
+
* @returns {Object} [returns.fieldReport] - Field tracking report if enabled
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const result = processLegalMarkdown(content, {
|
|
52
|
+
* enableFieldTracking: true,
|
|
53
|
+
* noClauses: false,
|
|
54
|
+
* noReferences: false
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* console.log(result.content); // Processed markdown
|
|
58
|
+
* console.log(result.metadata); // YAML front matter
|
|
59
|
+
* console.log(result.fieldReport); // Field usage report
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function processLegalMarkdown(content: string, options?: Omit<LegalMarkdownOptions, 'basePath' | 'exportPath'>): {
|
|
63
|
+
content: string;
|
|
64
|
+
metadata?: Record<string, any>;
|
|
65
|
+
fieldReport?: ReturnType<typeof fieldTracker.generateReport>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* UMD-compatible export object for browser environments
|
|
69
|
+
*
|
|
70
|
+
* This constant provides a namespace object that can be used in UMD builds
|
|
71
|
+
* and script tag implementations, making the library accessible through
|
|
72
|
+
* global window object or module systems.
|
|
73
|
+
*
|
|
74
|
+
* @constant {Object} LegalMarkdown
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // ES6 import
|
|
78
|
+
* import { LegalMarkdown } from 'legal-markdown-js/browser';
|
|
79
|
+
*
|
|
80
|
+
* // UMD/Script tag usage
|
|
81
|
+
* const result = window.LegalMarkdown.processLegalMarkdown(content);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const LegalMarkdown: {
|
|
85
|
+
processLegalMarkdown: typeof processLegalMarkdown;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AA0BH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,YAAY,CAAM,GAClE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,cAAc,CAAC,CAAC;CAC9D,CAuDA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;;CAEzB,CAAC"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Browser-Specific Entry Point for Legal Markdown Processing
|
|
4
|
+
*
|
|
5
|
+
* This module provides a browser-compatible version of the Legal Markdown
|
|
6
|
+
* processing library that excludes Node.js-specific features like file system
|
|
7
|
+
* operations and PDF generation. It's optimized for web environments and
|
|
8
|
+
* client-side processing.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - YAML front matter parsing and metadata extraction
|
|
12
|
+
* - Cross-reference processing and resolution
|
|
13
|
+
* - Optional clause conditional rendering
|
|
14
|
+
* - Mixin system for reusable content blocks
|
|
15
|
+
* - Header numbering and formatting
|
|
16
|
+
* - Field tracking for document highlighting
|
|
17
|
+
* - RST and LaTeX preprocessing support
|
|
18
|
+
* - UMD build compatibility for script tag usage
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { processLegalMarkdown } from 'legal-markdown-js/browser';
|
|
23
|
+
*
|
|
24
|
+
* // Browser-compatible document processing
|
|
25
|
+
* const result = processLegalMarkdown(content, {
|
|
26
|
+
* enableFieldTracking: true,
|
|
27
|
+
* noClauses: false
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* console.log(result.content); // Processed markdown
|
|
31
|
+
* console.log(result.metadata); // YAML front matter
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.LegalMarkdown = void 0;
|
|
36
|
+
exports.processLegalMarkdown = processLegalMarkdown;
|
|
37
|
+
const yaml_parser_1 = require("./core/parsers/yaml-parser");
|
|
38
|
+
const header_processor_1 = require("./core/processors/header-processor");
|
|
39
|
+
const clause_processor_1 = require("./core/processors/clause-processor");
|
|
40
|
+
const reference_processor_1 = require("./core/processors/reference-processor");
|
|
41
|
+
const mixin_processor_1 = require("./core/processors/mixin-processor");
|
|
42
|
+
// Import with fallback for browser environments
|
|
43
|
+
let convertRstToLegalMarkdownSync;
|
|
44
|
+
let convertLatexToLegalMarkdownSync;
|
|
45
|
+
try {
|
|
46
|
+
const rstParser = require('./extensions/rst-parser');
|
|
47
|
+
convertRstToLegalMarkdownSync = rstParser.convertRstToLegalMarkdownSync;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
// Fallback for browser environments without pandoc-wasm
|
|
51
|
+
convertRstToLegalMarkdownSync = (content) => content;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const latexParser = require('./extensions/latex-parser');
|
|
55
|
+
convertLatexToLegalMarkdownSync = latexParser.convertLatexToLegalMarkdownSync;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
// Fallback for browser environments without pandoc-wasm
|
|
59
|
+
convertLatexToLegalMarkdownSync = (content) => content;
|
|
60
|
+
}
|
|
61
|
+
const field_tracker_1 = require("./tracking/field-tracker");
|
|
62
|
+
/**
|
|
63
|
+
* Browser-compatible version of Legal Markdown processing
|
|
64
|
+
*
|
|
65
|
+
* This function provides the core Legal Markdown processing functionality
|
|
66
|
+
* optimized for browser environments. It excludes Node.js-specific features
|
|
67
|
+
* like file system operations while maintaining full compatibility with
|
|
68
|
+
* YAML parsing, content processing, and field tracking.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} content - The raw Legal Markdown content to process
|
|
71
|
+
* @param {Omit<LegalMarkdownOptions, 'basePath' | 'exportPath'>} [options={}] - Browser-compatible configuration options
|
|
72
|
+
* @returns {Object} Processing result containing processed content, metadata, and reports
|
|
73
|
+
* @returns {string} returns.content - The processed document content
|
|
74
|
+
* @returns {Record<string, any>} [returns.metadata] - Extracted YAML metadata
|
|
75
|
+
* @returns {Object} [returns.fieldReport] - Field tracking report if enabled
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const result = processLegalMarkdown(content, {
|
|
79
|
+
* enableFieldTracking: true,
|
|
80
|
+
* noClauses: false,
|
|
81
|
+
* noReferences: false
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* console.log(result.content); // Processed markdown
|
|
85
|
+
* console.log(result.metadata); // YAML front matter
|
|
86
|
+
* console.log(result.fieldReport); // Field usage report
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
function processLegalMarkdown(content, options = {}) {
|
|
90
|
+
// Clear field tracker for new document
|
|
91
|
+
field_tracker_1.fieldTracker.clear();
|
|
92
|
+
// Convert RST or LaTeX to legal markdown if needed (before YAML parsing)
|
|
93
|
+
let preprocessedContent = convertRstToLegalMarkdownSync(content);
|
|
94
|
+
preprocessedContent = convertLatexToLegalMarkdownSync(preprocessedContent);
|
|
95
|
+
// Parse YAML Front Matter
|
|
96
|
+
const { content: contentWithoutYaml, metadata } = (0, yaml_parser_1.parseYamlFrontMatter)(preprocessedContent, options.throwOnYamlError);
|
|
97
|
+
// If only processing YAML, return early
|
|
98
|
+
if (options.yamlOnly) {
|
|
99
|
+
return { content: contentWithoutYaml, metadata };
|
|
100
|
+
}
|
|
101
|
+
let processedContent = contentWithoutYaml;
|
|
102
|
+
// Process optional clauses
|
|
103
|
+
if (!options.noClauses) {
|
|
104
|
+
processedContent = (0, clause_processor_1.processOptionalClauses)(processedContent, metadata);
|
|
105
|
+
}
|
|
106
|
+
// Process cross references
|
|
107
|
+
if (!options.noReferences) {
|
|
108
|
+
processedContent = (0, reference_processor_1.processCrossReferences)(processedContent, metadata);
|
|
109
|
+
}
|
|
110
|
+
// Process mixins
|
|
111
|
+
if (!options.noMixins) {
|
|
112
|
+
processedContent = (0, mixin_processor_1.processMixins)(processedContent, metadata, options);
|
|
113
|
+
}
|
|
114
|
+
// Process headers (numbering, etc)
|
|
115
|
+
if (!options.noHeaders) {
|
|
116
|
+
processedContent = (0, header_processor_1.processHeaders)(processedContent, metadata, {
|
|
117
|
+
noReset: options.noReset,
|
|
118
|
+
noIndent: options.noIndent,
|
|
119
|
+
enableFieldTracking: options.enableFieldTracking,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// Apply field tracking to content if highlighting is enabled
|
|
123
|
+
if (options.enableFieldTracking) {
|
|
124
|
+
processedContent = field_tracker_1.fieldTracker.applyFieldTracking(processedContent);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
content: processedContent,
|
|
128
|
+
metadata,
|
|
129
|
+
fieldReport: options.enableFieldTracking ? field_tracker_1.fieldTracker.generateReport() : undefined,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* UMD-compatible export object for browser environments
|
|
134
|
+
*
|
|
135
|
+
* This constant provides a namespace object that can be used in UMD builds
|
|
136
|
+
* and script tag implementations, making the library accessible through
|
|
137
|
+
* global window object or module systems.
|
|
138
|
+
*
|
|
139
|
+
* @constant {Object} LegalMarkdown
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // ES6 import
|
|
143
|
+
* import { LegalMarkdown } from 'legal-markdown-js/browser';
|
|
144
|
+
*
|
|
145
|
+
* // UMD/Script tag usage
|
|
146
|
+
* const result = window.LegalMarkdown.processLegalMarkdown(content);
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
exports.LegalMarkdown = {
|
|
150
|
+
processLegalMarkdown,
|
|
151
|
+
};
|
|
152
|
+
// Create global window object for script tag usage
|
|
153
|
+
if (typeof window !== 'undefined') {
|
|
154
|
+
// eslint-disable-next-line no-undef
|
|
155
|
+
window.LegalMarkdown = exports.LegalMarkdown;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],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AC;AAEF,mDAAmD;AACnD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,oCAAoC;IACnC,MAAc,CAAC,aAAa,GAAG,qBAAa,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Command Line Interface for Legal Markdown Processing
|
|
4
|
+
*
|
|
5
|
+
* This module provides a comprehensive CLI tool for processing Legal Markdown
|
|
6
|
+
* documents with support for various output formats, processing options, and
|
|
7
|
+
* input/output methods (files, stdin/stdout).
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - File and stdin input processing
|
|
11
|
+
* - Multiple output formats (Markdown, HTML, PDF)
|
|
12
|
+
* - Comprehensive processing options and flags
|
|
13
|
+
* - Field highlighting and styling options
|
|
14
|
+
* - Metadata export capabilities
|
|
15
|
+
* - Error handling and user feedback
|
|
16
|
+
* - Debug mode support
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```bash
|
|
20
|
+
* # Process a file
|
|
21
|
+
* legal-md input.md output.md
|
|
22
|
+
*
|
|
23
|
+
* # Generate PDF with highlighting
|
|
24
|
+
* legal-md input.md --pdf --highlight --title "Contract"
|
|
25
|
+
*
|
|
26
|
+
* # Process from stdin
|
|
27
|
+
* cat input.md | legal-md --stdin --stdout
|
|
28
|
+
*
|
|
29
|
+
* # Export metadata
|
|
30
|
+
* legal-md input.md --export-yaml --output-path metadata.yaml
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG"}
|