@udx/md2html 1.0.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 ADDED
@@ -0,0 +1,219 @@
1
+ # @udx/md2html - Magazine-Quality Markdown to HTML Converter
2
+
3
+ A sophisticated tool for converting markdown files into a single, visually polished HTML document with magazine-quality styling. Perfect for creating professional documentation, reports, and publications from markdown source files.
4
+
5
+ ## Key Features
6
+
7
+ - **Markdown Consolidation**: Intelligently combines and sorts multiple markdown files into a single cohesive document
8
+ - **Magazine-Quality Styling**: Applies high-end editorial styling with precise typography and spacing
9
+ - **Code Block Enhancements**: Syntax highlighting with file type indicators and copy buttons
10
+ - **Responsive Images**: Handles high-resolution images with proper sizing and caption support
11
+ - **Watch Mode**: Automatically rebuilds when source files change with intelligent debouncing
12
+ - **Print Optimization**: Carefully crafted print styling for document printing and PDF generation
13
+ - **Table of Contents**: Auto-generates navigable table of contents from document structure
14
+ - **Customizable**: External CSS, JavaScript, and HTML templates for easy customization
15
+
16
+ ## Architecture
17
+
18
+ The tool has been refactored with a clean, modular architecture:
19
+
20
+ - **Handlebars Templates**: The HTML structure is defined in a Handlebars template (`static/view.hbs`)
21
+ - **External CSS**: All styling is maintained in a dedicated CSS file (`static/styles.css`)
22
+ - **External JavaScript**: All DOM post-processing in a separate JS file (`static/scripts.js`)
23
+ - **Single Output File**: Despite the modular development approach, the output is a self-contained HTML file with all CSS and JS embedded inline
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ # Install globally
29
+ npm install -g @udx/md2html
30
+
31
+ # Or install locally in your project
32
+ npm install --save-dev @udx/md2html
33
+ ```
34
+
35
+ ## Usage Examples
36
+
37
+ ```bash
38
+ # Convert a single markdown file to HTML
39
+ md2html --src path/to/file.md --out output.html
40
+
41
+ # Convert all markdown files in a directory
42
+ md2html --src path/to/markdown/dir --out documentation.html
43
+
44
+ # Watch for changes and rebuild automatically
45
+ md2html --src path/to/markdown/dir --out documentation.html --watch
46
+
47
+ # Enable debug output
48
+ md2html --src path/to/markdown/dir --out documentation.html --debug
49
+ ```
50
+
51
+ ## CLI Options
52
+
53
+ | Option | Description |
54
+ |--------|-------------|
55
+ | `-s, --src <path>` | Source markdown file or directory (required) |
56
+ | `-o, --out <path>` | Output HTML file path (required) |
57
+ | `-w, --watch` | Watch for changes and rebuild automatically |
58
+ | `-d, --debug` | Enable debug logging |
59
+ | `-h, --help` | Display help information |
60
+ | `-v, --version` | Output the version number |
61
+
62
+ ## Markdown Features
63
+
64
+ ### Document Metadata
65
+
66
+ Add metadata at the top of your markdown files using HTML comments:
67
+
68
+ ```markdown
69
+ <!-- title: My Document Title -->
70
+ <!-- description: A detailed description of my document -->
71
+ <!-- author: Your Name -->
72
+ <!-- date: January 1, 2025 -->
73
+ <!-- version: v1.0 -->
74
+ ```
75
+
76
+ ### Table of Contents
77
+
78
+ Add a table of contents anywhere in your document:
79
+
80
+ ```markdown
81
+ <!-- TOC -->
82
+ ```
83
+
84
+ ### Code Blocks
85
+
86
+ Code blocks are beautifully formatted with syntax highlighting and file type indicators:
87
+
88
+ ````markdown
89
+ ```javascript
90
+ const greeting = 'Hello, world!';
91
+ console.log(greeting);
92
+ ```
93
+ ````
94
+
95
+ ### Image Captions
96
+
97
+ Add captions to images with this syntax:
98
+
99
+ ```markdown
100
+ ![Alt text](path/to/image.jpg)
101
+ *This is the image caption*
102
+ ```
103
+
104
+ ## Customization
105
+
106
+ This tool is designed to be easily customizable:
107
+
108
+ - `static/view.hbs` - Edit the HTML template structure
109
+ - `static/styles.css` - Modify the styling
110
+ - `static/scripts.js` - Adjust the DOM post-processing
111
+
112
+ ## Architecture Details
113
+
114
+ The refactored architecture follows modern principles:
115
+
116
+ 1. **Modular Development**: Template, styles, and scripts are maintained in separate files for easy editing
117
+ 2. **Self-Contained Output**: The output is a single HTML file with all CSS and JS embedded inline
118
+ 3. **Template-Based**: Uses Handlebars for cleaner template management
119
+ 4. **Efficient File Watching**: Uses Chokidar with debouncing for reliable file watching
120
+
121
+ ## Contributing
122
+
123
+ Contributions are welcome! Please feel free to submit a Pull Request.
124
+
125
+ ### Basic Usage
126
+
127
+ ```bash
128
+ # Convert markdown files to a single HTML document
129
+ md2html --src /path/to/markdown/dir --out output.html
130
+
131
+ # Watch for changes and rebuild automatically
132
+ md2html --src /path/to/markdown/dir --out output.html --watch
133
+
134
+ # Enable debug logging
135
+ md2html --src /path/to/markdown/dir --out output.html --debug
136
+ ```
137
+
138
+ ### Integration with Other UDX Tools
139
+
140
+ ```bash
141
+ # Process content with mcurl, then convert to HTML
142
+ mcurl https://udx.io/guidance | mq --clean-content > content.md
143
+ md2html --src ./content.md --out guidance.html
144
+
145
+ # Create documentation from GitHub repository
146
+ gh repo clone owner/repo
147
+ md2html --src ./repo/docs --out documentation.html
148
+ ```
149
+
150
+ ## Command Line Options
151
+
152
+ ```
153
+ Options:
154
+ -V, --version output the version number
155
+ -s, --src <directory> Source directory containing markdown files
156
+ -o, --out <file> Output HTML file path
157
+ -w, --watch Watch for changes and rebuild automatically (default: false)
158
+ -d, --debug Enable debug logging (default: false)
159
+ -h, --help display help for command
160
+ ```
161
+
162
+ ## Output Example
163
+
164
+ The generated HTML document includes:
165
+
166
+ - Document header with title, description, author, and date
167
+ - Table of contents with links to sections
168
+ - Content sections with proper heading hierarchy
169
+ - Google Docs-like styling for professional appearance
170
+ - Print-optimized layout with page breaks
171
+ - Responsive design for various screen sizes
172
+
173
+ ## API Usage
174
+
175
+ md2html can also be used programmatically:
176
+
177
+ ```javascript
178
+ import { buildHtml, watchMarkdown } from '@udx/md2html';
179
+
180
+ // Build HTML once
181
+ await buildHtml('/path/to/markdown/dir', 'output.html');
182
+
183
+ // Watch for changes
184
+ watchMarkdown('/path/to/markdown/dir', 'output.html');
185
+ ```
186
+
187
+ ## Best Practices
188
+
189
+ ### Document Organization
190
+
191
+ - Organize markdown files with numeric prefixes (e.g., `01_introduction.md`, `02_architecture.md`)
192
+ - Use consistent heading levels across documents
193
+ - Include metadata in HTML comments for better document information:
194
+ ```markdown
195
+ <!-- author: UDX Team -->
196
+ <!-- date: April 30, 2025 -->
197
+ <!-- version: 1.0 -->
198
+ ```
199
+
200
+ ### Integration Patterns
201
+
202
+ - **Documentation Pipeline**: Generate documentation from multiple sources
203
+ ```bash
204
+ # Combine API docs and markdown files
205
+ mcurl https://api.example.com/docs | mq --clean-content > api-docs.md
206
+ cp api-docs.md ./docs/
207
+ md2html --src ./docs --out complete-documentation.html
208
+ ```
209
+
210
+ - **Content Transformation**: Convert between formats
211
+ ```bash
212
+ # Convert HTML to markdown, then to styled HTML
213
+ mcurl https://udx.io/about > about.md
214
+ md2html --src ./about.md --out about-styled.html
215
+ ```
216
+
217
+ ## License
218
+
219
+ ISC