-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown-to-html.js
More file actions
62 lines (45 loc) · 1.33 KB
/
markdown-to-html.js
File metadata and controls
62 lines (45 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Convert Markdown to HTML using DocForge API
// Usage: node markdown-to-html.js
const markdown = `
# Project Update — Week 12
## Summary
This week we shipped **three new features** and fixed *two critical bugs*.
### Features
1. User dashboard with real-time metrics
2. Export to CSV functionality
3. Dark mode toggle (finally!)
### Bug Fixes
- Fixed memory leak in WebSocket handler
- Corrected timezone offset in date picker
### Code Example
\`\`\`javascript
const dashboard = await createDashboard({
metrics: ['users', 'revenue', 'churn'],
refresh: '30s'
});
\`\`\`
> Next week: performance optimization sprint.
---
*Generated on ${new Date().toISOString().split('T')[0]}*
`;
async function convert() {
const res = await fetch('https://docforge-api.vercel.app/api/md-to-html', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ markdown })
});
if (!res.ok) {
console.error(`Error: ${res.status} ${res.statusText}`);
const body = await res.text();
console.error(body);
process.exit(1);
}
const { html, meta } = await res.json();
console.log('=== Metadata ===');
console.log(`Word count: ${meta.wordCount}`);
console.log(`Headings: ${meta.headings.join(', ')}`);
console.log();
console.log('=== HTML Output ===');
console.log(html);
}
convert();