markdown-slides-cli 1.0.4 ā 1.0.6
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 +83 -9
- package/index.js +88 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# š Markdown Slides
|
|
2
2
|
|
|
3
|
-
> A powerful, interactive markdown slide presentation tool with live editing, minimap view, and fullscreen support. Create beautiful presentations from simple markdown files!
|
|
3
|
+
> A powerful, interactive markdown slide presentation tool with live editing, minimap view, and fullscreen and stdin support. Create beautiful presentations from simple markdown files!
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
## ⨠Features
|
|
9
9
|
|
|
10
10
|
- š **Markdown-Based** - Write slides in simple markdown syntax
|
|
11
|
+
- šÆ **Flexible Input** - Load from files or stdin (pipe support)
|
|
11
12
|
- šŗļø **Minimap View** - Navigate slides with thumbnail overview
|
|
12
13
|
- āļø **Live Editor** - Built-in Monaco editor (VS Code's editor)
|
|
13
14
|
- šØ **Beautiful Rendering** - Full markdown support with syntax highlighting
|
|
@@ -59,9 +60,12 @@ function hello() {
|
|
|
59
60
|
console.log('Hello World!');
|
|
60
61
|
}
|
|
61
62
|
```
|
|
63
|
+
```
|
|
62
64
|
|
|
63
65
|
### 2. Run the Presentation
|
|
64
66
|
|
|
67
|
+
**From a file:**
|
|
68
|
+
|
|
65
69
|
```bash
|
|
66
70
|
node markdown-slides.js -f slides.md
|
|
67
71
|
```
|
|
@@ -72,13 +76,35 @@ Or with global installation:
|
|
|
72
76
|
markdown-slides -f slides.md
|
|
73
77
|
```
|
|
74
78
|
|
|
79
|
+
**From stdin (pipe):**
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Pipe from a file
|
|
83
|
+
cat slides.md | markdown-slides
|
|
84
|
+
|
|
85
|
+
# Pipe from echo
|
|
86
|
+
echo "# Slide 1\n---\n# Slide 2" | markdown-slides
|
|
87
|
+
|
|
88
|
+
# Using heredoc
|
|
89
|
+
markdown-slides << EOF
|
|
90
|
+
# Welcome
|
|
91
|
+
This is my presentation
|
|
92
|
+
---
|
|
93
|
+
# Second Slide
|
|
94
|
+
More content here
|
|
95
|
+
EOF
|
|
96
|
+
|
|
97
|
+
# Combine with other commands
|
|
98
|
+
curl https://raw.githubusercontent.com/user/repo/main/slides.md | markdown-slides
|
|
99
|
+
```
|
|
100
|
+
|
|
75
101
|
Your browser will automatically open with your presentation!
|
|
76
102
|
|
|
77
103
|
## š® CLI Options
|
|
78
104
|
|
|
79
105
|
| Option | Alias | Description | Default |
|
|
80
106
|
|--------|-------|-------------|---------|
|
|
81
|
-
| `--file` | `-f` | Markdown file path (
|
|
107
|
+
| `--file` | `-f` | Markdown file path (optional if using stdin) | - |
|
|
82
108
|
| `--port` | `-p` | Server port | `3457` |
|
|
83
109
|
| `--title` | `-t` | Presentation title | `Markdown Slides` |
|
|
84
110
|
| `--theme` | - | Slide theme (dark/light/blue) | `dark` |
|
|
@@ -86,6 +112,8 @@ Your browser will automatically open with your presentation!
|
|
|
86
112
|
|
|
87
113
|
### Examples
|
|
88
114
|
|
|
115
|
+
**File-based:**
|
|
116
|
+
|
|
89
117
|
```bash
|
|
90
118
|
# Basic usage
|
|
91
119
|
markdown-slides -f presentation.md
|
|
@@ -97,6 +125,22 @@ markdown-slides -f slides.md -p 8080 -t "My Presentation"
|
|
|
97
125
|
markdown-slides -f deck.md --theme blue
|
|
98
126
|
```
|
|
99
127
|
|
|
128
|
+
**Stdin-based:**
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# From pipe
|
|
132
|
+
cat slides.md | markdown-slides
|
|
133
|
+
|
|
134
|
+
# With options
|
|
135
|
+
cat slides.md | markdown-slides -p 8080 -t "My Talk"
|
|
136
|
+
|
|
137
|
+
# From command output
|
|
138
|
+
generate-slides.sh | markdown-slides
|
|
139
|
+
|
|
140
|
+
# From URL
|
|
141
|
+
curl https://example.com/slides.md | markdown-slides
|
|
142
|
+
```
|
|
143
|
+
|
|
100
144
|
## āØļø Keyboard Shortcuts
|
|
101
145
|
|
|
102
146
|
| Key | Action |
|
|
@@ -297,9 +341,7 @@ curl -H "Authorization: Bearer TOKEN" /api/users
|
|
|
297
341
|
|
|
298
342
|
---
|
|
299
343
|
|
|
300
|
-
#
|
|
301
|
-
|
|
302
|
-
### Technologies Used
|
|
344
|
+
# Technologies Used
|
|
303
345
|
|
|
304
346
|
- **Node.js** - Runtime environment
|
|
305
347
|
- **Commander** - CLI argument parsing
|
|
@@ -315,6 +357,8 @@ curl -H "Authorization: Bearer TOKEN" /api/users
|
|
|
315
357
|
- š **Documentation** - Product demos, guides
|
|
316
358
|
- šØāš« **Training Materials** - Workshops, courses
|
|
317
359
|
- š **Data Presentations** - Reports with code examples
|
|
360
|
+
- š **Dynamic Content** - Generate slides from scripts and pipe to viewer
|
|
361
|
+
- š **Remote Content** - Fetch and present markdown from URLs
|
|
318
362
|
|
|
319
363
|
## š” Tips & Tricks
|
|
320
364
|
|
|
@@ -337,6 +381,28 @@ curl -H "Authorization: Bearer TOKEN" /api/users
|
|
|
337
381
|
|
|
338
382
|
### Advanced Usage
|
|
339
383
|
|
|
384
|
+
**Stdin Input**: Pipe markdown directly without creating files
|
|
385
|
+
```bash
|
|
386
|
+
cat slides.md | markdown-slides -p 3000
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**Dynamic Generation**: Combine with other tools
|
|
390
|
+
```bash
|
|
391
|
+
# Generate slides from a script
|
|
392
|
+
./generate-report.sh | markdown-slides
|
|
393
|
+
|
|
394
|
+
# Fetch from URL
|
|
395
|
+
curl https://example.com/slides.md | markdown-slides
|
|
396
|
+
|
|
397
|
+
# Use with heredoc for quick presentations
|
|
398
|
+
markdown-slides << 'EOF'
|
|
399
|
+
# Quick Demo
|
|
400
|
+
This is a quick presentation
|
|
401
|
+
---
|
|
402
|
+
# Thank You!
|
|
403
|
+
EOF
|
|
404
|
+
```
|
|
405
|
+
|
|
340
406
|
**Custom Styling**: Edit the embedded CSS in `markdown-slides.js`
|
|
341
407
|
|
|
342
408
|
**Custom Themes**: Modify the color scheme in the `<style>` section
|
|
@@ -371,6 +437,17 @@ markdown-slides -f slides.md -p 8080
|
|
|
371
437
|
- Check for proper slide separators (`---`)
|
|
372
438
|
- Verify file encoding is UTF-8
|
|
373
439
|
|
|
440
|
+
### No Input Provided Error
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Either provide a file
|
|
444
|
+
markdown-slides -f slides.md
|
|
445
|
+
|
|
446
|
+
# Or pipe content via stdin
|
|
447
|
+
cat slides.md | markdown-slides
|
|
448
|
+
echo "# Slide" | markdown-slides
|
|
449
|
+
```
|
|
450
|
+
|
|
374
451
|
## š Requirements
|
|
375
452
|
|
|
376
453
|
- Node.js >= 14.0.0
|
|
@@ -396,14 +473,10 @@ All other features (Marked, Monaco Editor, Tailwind CSS) load from CDNs.
|
|
|
396
473
|
- [ ] Video embed support
|
|
397
474
|
- [ ] Auto-save functionality
|
|
398
475
|
|
|
399
|
-
|
|
400
|
-
|
|
401
476
|
## š License
|
|
402
477
|
|
|
403
478
|
MIT License (c) Mohan Chinnappan
|
|
404
479
|
|
|
405
|
-
|
|
406
|
-
|
|
407
480
|
---
|
|
408
481
|
|
|
409
482
|
## š Quick Reference Card
|
|
@@ -414,6 +487,7 @@ MIT License (c) Mohan Chinnappan
|
|
|
414
487
|
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
|
|
415
488
|
ā Start Server: ā
|
|
416
489
|
ā markdown-slides -f slides.md ā
|
|
490
|
+
ā cat slides.md | markdown-slides ā
|
|
417
491
|
ā ā
|
|
418
492
|
ā Keyboard Shortcuts: ā
|
|
419
493
|
ā ā / Space Next slide ā
|
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const { exec } = require('child_process');
|
|
|
12
12
|
program
|
|
13
13
|
.name('markdown-slides')
|
|
14
14
|
.description('Interactive markdown slide presentation with live editing')
|
|
15
|
-
.
|
|
15
|
+
.option('-f, --file <path>', 'markdown file with slides')
|
|
16
16
|
.option('-p, --port <number>', 'server port', '3457')
|
|
17
17
|
.option('-t, --title <title>', 'presentation title', 'Markdown Slides')
|
|
18
18
|
.option('--theme <theme>', 'slide theme: dark, light, blue', 'dark')
|
|
@@ -20,20 +20,62 @@ program
|
|
|
20
20
|
|
|
21
21
|
const opts = program.opts();
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
async function readStdin() {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
let data = '';
|
|
26
|
+
process.stdin.setEncoding('utf8');
|
|
27
|
+
process.stdin.on('data', chunk => (data += chunk));
|
|
28
|
+
process.stdin.on('end', () => resolve(data));
|
|
29
|
+
process.stdin.on('error', reject);
|
|
30
|
+
});
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
async function getMarkdownContent() {
|
|
34
|
+
// Check if stdin has data (piped input)
|
|
35
|
+
const isStdin = !process.stdin.isTTY;
|
|
36
|
+
|
|
37
|
+
if (opts.file) {
|
|
38
|
+
// File was provided
|
|
39
|
+
if (!fs.existsSync(opts.file)) {
|
|
40
|
+
console.error(`Error: File not found: ${opts.file}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
content: fs.readFileSync(opts.file, 'utf-8'),
|
|
45
|
+
fileName: path.basename(opts.file),
|
|
46
|
+
source: 'file'
|
|
47
|
+
};
|
|
48
|
+
} else if (isStdin) {
|
|
49
|
+
// Read from stdin
|
|
50
|
+
const content = await readStdin();
|
|
51
|
+
if (!content.trim()) {
|
|
52
|
+
console.error('Error: No content provided via stdin');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
content,
|
|
57
|
+
fileName: 'slides.md',
|
|
58
|
+
source: 'stdin'
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
// No input provided
|
|
62
|
+
console.error('Error: No input provided. Use -f <file> or pipe markdown content.');
|
|
63
|
+
console.error('\nExamples:');
|
|
64
|
+
console.error(' markdown-slides -f presentation.md');
|
|
65
|
+
console.error(' cat slides.md | markdown-slides');
|
|
66
|
+
console.error(' echo "# Slide 1\\n---\\n# Slide 2" | markdown-slides');
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function main() {
|
|
72
|
+
const { content: markdownContent, fileName, source } = await getMarkdownContent();
|
|
31
73
|
|
|
32
|
-
console.log(`\nš Markdown Slides Viewer`);
|
|
33
|
-
console.log(`
|
|
34
|
-
console.log(`\nš Starting server on http://localhost:${opts.port}`);
|
|
74
|
+
console.log(`\nš Markdown Slides Viewer`);
|
|
75
|
+
console.log(`Source: ${source === 'file' ? fileName : 'stdin'}`);
|
|
76
|
+
console.log(`\nš Starting server on http://localhost:${opts.port}`);
|
|
35
77
|
|
|
36
|
-
const html = `<!DOCTYPE html>
|
|
78
|
+
const html = `<!DOCTYPE html>
|
|
37
79
|
<html lang="en" class="dark">
|
|
38
80
|
<head>
|
|
39
81
|
<meta charset="UTF-8">
|
|
@@ -469,36 +511,42 @@ const html = `<!DOCTYPE html>
|
|
|
469
511
|
</body>
|
|
470
512
|
</html>`;
|
|
471
513
|
|
|
472
|
-
// Create HTTP server
|
|
473
|
-
const server = http.createServer((req, res) => {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
});
|
|
514
|
+
// Create HTTP server
|
|
515
|
+
const server = http.createServer((req, res) => {
|
|
516
|
+
if (req.url === '/') {
|
|
517
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
518
|
+
res.end(html);
|
|
519
|
+
} else {
|
|
520
|
+
res.writeHead(404);
|
|
521
|
+
res.end('Not Found');
|
|
522
|
+
}
|
|
523
|
+
});
|
|
482
524
|
|
|
483
|
-
server.listen(opts.port, () => {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
525
|
+
server.listen(opts.port, () => {
|
|
526
|
+
const url = `http://localhost:${opts.port}`;
|
|
527
|
+
console.log(`ā
Server running at ${url}\n`);
|
|
528
|
+
|
|
529
|
+
// Open browser
|
|
530
|
+
const command = process.platform === 'darwin' ? 'open' :
|
|
531
|
+
process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
532
|
+
exec(`${command} ${url}`, (err) => {
|
|
533
|
+
if (err) console.log('Please open the URL manually in your browser');
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
console.log('Press Ctrl+C to stop the server\n');
|
|
537
|
+
console.log('Keyboard shortcuts:');
|
|
538
|
+
console.log(' ā / Space Next slide');
|
|
539
|
+
console.log(' ā Previous slide');
|
|
540
|
+
console.log(' Home First slide');
|
|
541
|
+
console.log(' End Last slide');
|
|
542
|
+
console.log(' F / F11 Fullscreen');
|
|
543
|
+
console.log(' E Open editor');
|
|
544
|
+
console.log(' M Toggle minimap');
|
|
545
|
+
console.log(' ESC Close editor');
|
|
492
546
|
});
|
|
547
|
+
}
|
|
493
548
|
|
|
494
|
-
|
|
495
|
-
console.
|
|
496
|
-
|
|
497
|
-
console.log(' ā Previous slide');
|
|
498
|
-
console.log(' Home First slide');
|
|
499
|
-
console.log(' End Last slide');
|
|
500
|
-
console.log(' F / F11 Fullscreen');
|
|
501
|
-
console.log(' E Open editor');
|
|
502
|
-
console.log(' M Toggle minimap');
|
|
503
|
-
console.log(' ESC Close editor');
|
|
549
|
+
main().catch(err => {
|
|
550
|
+
console.error('Error:', err.message);
|
|
551
|
+
process.exit(1);
|
|
504
552
|
});
|