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.
Files changed (3) hide show
  1. package/README.md +83 -9
  2. package/index.js +88 -40
  3. 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
  ![Node.js](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen)
6
6
  ![License](https://img.shields.io/badge/license-MIT-green)
@@ -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 (required) | - |
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
- .requiredOption('-f, --file <path>', 'markdown file with slides')
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
- // Validate markdown file
24
- if (!fs.existsSync(opts.file)) {
25
- console.error(`Error: File not found: ${opts.file}`);
26
- process.exit(1);
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
- const markdownContent = fs.readFileSync(opts.file, 'utf-8');
30
- const fileName = path.basename(opts.file);
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(`File: ${fileName}`);
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
- if (req.url === '/') {
475
- res.writeHead(200, { 'Content-Type': 'text/html' });
476
- res.end(html);
477
- } else {
478
- res.writeHead(404);
479
- res.end('Not Found');
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
- const url = `http://localhost:${opts.port}`;
485
- console.log(`āœ… Server running at ${url}\n`);
486
-
487
- // Open browser
488
- const command = process.platform === 'darwin' ? 'open' :
489
- process.platform === 'win32' ? 'start' : 'xdg-open';
490
- exec(`${command} ${url}`, (err) => {
491
- if (err) console.log('Please open the URL manually in your browser');
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
- console.log('Press Ctrl+C to stop the server\n');
495
- console.log('Keyboard shortcuts:');
496
- console.log(' → / Space Next slide');
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-slides-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Interactive markdown slide presentation with live editing and minimap view",
5
5
  "main": "index.js",
6
6
  "publisher": "mohanchinnappan",