create-marp-presentation 1.0.1 → 1.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/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # Create Marp Presentation
2
2
 
3
- Создайте новую Marp презентацию одной командой.
3
+ Create a new Marp presentation with a single command.
4
4
 
5
- ## Установка
5
+ ## Installation
6
6
 
7
7
  ```bash
8
8
  npx create-marp-presentation my-presentation
9
9
  ```
10
10
 
11
- ## Использование
11
+ ## Usage
12
12
 
13
13
  ```bash
14
14
  cd my-presentation
@@ -16,7 +16,7 @@ npm run dev # Live preview
16
16
  npm run build:all # Build all formats
17
17
  ```
18
18
 
19
- ## Возможности
19
+ ## Features
20
20
 
21
21
  - 🚀 One-command setup
22
22
  - 📝 Markdown slides
@@ -25,10 +25,41 @@ npm run build:all # Build all formats
25
25
  - 📁 Static files support
26
26
  - 🔥 Live preview
27
27
 
28
- ## Документация
28
+ ## Local Testing
29
29
 
30
- После создания проекта читайте README в папке проекта.
30
+ To test project generation without publishing to npm:
31
31
 
32
- ## Лицензия
32
+ ```bash
33
+ # Clone the repository
34
+ git clone https://github.com/echernyshev/marp-presentation-template.git
35
+ cd marp-presentation-template
36
+
37
+ # Install dependencies for tests
38
+ npm install
39
+
40
+ # Run tests
41
+ npm test
42
+
43
+ # Create a test project (interactive mode)
44
+ node index.js test-project
45
+
46
+ # Check the contents
47
+ cd test-project
48
+ ls -la
49
+ npm run dev
50
+ ```
51
+
52
+ Other example commands:
53
+
54
+ ```bash
55
+ # Create a test project without examples
56
+ echo "n" | node index.js test-project-minimal
57
+ ```
58
+
59
+ ## Documentation
60
+
61
+ After creating a project, read the README in the project folder.
62
+
63
+ ## License
33
64
 
34
65
  MIT
package/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const { spawnSync } = require('child_process');
6
+ const readline = require('readline');
6
7
 
7
8
  const projectName = process.argv[2];
8
9
 
@@ -22,6 +23,57 @@ if (!validName.test(projectName)) {
22
23
 
23
24
  const projectPath = path.join(process.cwd(), projectName);
24
25
 
26
+ // Запрос на создание примеров слайдов
27
+ async function askCreateExamples() {
28
+ return new Promise((resolve) => {
29
+ // Интерактивный режим — спрашиваем пользователя
30
+ if (process.stdin.isTTY) {
31
+ const rl = readline.createInterface({
32
+ input: process.stdin,
33
+ output: process.stdout
34
+ });
35
+
36
+ rl.question('Create example slides file? (Y/n) ', (answer) => {
37
+ rl.close();
38
+ const normalized = answer.toLowerCase().trim();
39
+ resolve(normalized !== 'n' && normalized !== 'no');
40
+ });
41
+ } else {
42
+ // Неинтерактивный режим — читаем из stdin если есть данные
43
+ let input = '';
44
+ process.stdin.setEncoding('utf8');
45
+
46
+ process.stdin.on('readable', () => {
47
+ let chunk;
48
+ while ((chunk = process.stdin.read()) !== null) {
49
+ input += chunk;
50
+ }
51
+ });
52
+
53
+ process.stdin.on('end', () => {
54
+ const normalized = input.toLowerCase().trim();
55
+ // Если ввод пустой, создаём примеры по умолчанию
56
+ if (normalized === '') {
57
+ resolve(true);
58
+ } else {
59
+ resolve(normalized !== 'n' && normalized !== 'no');
60
+ }
61
+ });
62
+
63
+ // Если stdin не имеет данных сразу, завершаем
64
+ if (process.stdin.readableLength === 0) {
65
+ // Даем небольшое время на появление данных
66
+ setTimeout(() => {
67
+ if (input === '') {
68
+ process.stdin.destroy();
69
+ resolve(true);
70
+ }
71
+ }, 10);
72
+ }
73
+ }
74
+ });
75
+ }
76
+
25
77
  // Validate path to prevent traversal attacks
26
78
  const resolvedPath = path.resolve(projectPath);
27
79
  if (!resolvedPath.startsWith(path.resolve(process.cwd()))) {
@@ -38,59 +90,95 @@ if (fs.existsSync(projectPath)) {
38
90
  // Получаем путь к template
39
91
  const templatePath = path.join(__dirname, 'template');
40
92
 
93
+ // Рекурсивное копирование директории
94
+ const copyDir = (src, dest) => {
95
+ const entries = fs.readdirSync(src, { withFileTypes: true });
96
+
97
+ for (const entry of entries) {
98
+ const srcPath = path.join(src, entry.name);
99
+ const destPath = path.join(dest, entry.name);
100
+
101
+ if (entry.isDirectory()) {
102
+ fs.mkdirSync(destPath, { recursive: true });
103
+ copyDir(srcPath, destPath);
104
+ } else {
105
+ fs.copyFileSync(srcPath, destPath);
106
+ }
107
+ }
108
+ };
109
+
110
+ // Копирование опциональных файлов
111
+ const copyOptionalFiles = (destPath) => {
112
+ const optionalPath = path.join(__dirname, 'template-optional');
113
+
114
+ // Копируем examples.md
115
+ const examplesSrc = path.join(optionalPath, 'examples.md');
116
+ const examplesDest = path.join(destPath, 'examples.md');
117
+ if (fs.existsSync(examplesSrc)) {
118
+ fs.copyFileSync(examplesSrc, examplesDest);
119
+ }
120
+
121
+ // Копируем демо-изображение
122
+ const demoImageSrc = path.join(optionalPath, 'static', 'demo-image.png');
123
+ const demoImageDest = path.join(destPath, 'static', 'demo-image.png');
124
+ if (fs.existsSync(demoImageSrc)) {
125
+ fs.copyFileSync(demoImageSrc, demoImageDest);
126
+ }
127
+ };
128
+
41
129
  console.log(`Creating Marp presentation: ${projectName}`);
42
130
  console.log();
43
131
 
44
- try {
45
- // Создаём папку проекта
46
- fs.mkdirSync(projectPath, { recursive: true });
47
-
48
- // Рекурсивно копируем template
49
- const copyDir = (src, dest) => {
50
- const entries = fs.readdirSync(src, { withFileTypes: true });
132
+ // Основной async flow
133
+ (async () => {
134
+ try {
135
+ // Запрашиваем создание примеров
136
+ const createExamples = await askCreateExamples();
51
137
 
52
- for (const entry of entries) {
53
- const srcPath = path.join(src, entry.name);
54
- const destPath = path.join(dest, entry.name);
138
+ // Создаём папку проекта
139
+ fs.mkdirSync(projectPath, { recursive: true });
55
140
 
56
- if (entry.isDirectory()) {
57
- fs.mkdirSync(destPath, { recursive: true });
58
- copyDir(srcPath, destPath);
59
- } else {
60
- fs.copyFileSync(srcPath, destPath);
61
- }
62
- }
63
- };
141
+ // Рекурсивно копируем template
142
+ copyDir(templatePath, projectPath);
64
143
 
65
- copyDir(templatePath, projectPath);
144
+ console.log('✓ Project created');
66
145
 
67
- console.log('✓ Project created');
68
- console.log();
146
+ // Копируем опциональные файлы
147
+ if (createExamples) {
148
+ copyOptionalFiles(projectPath);
149
+ console.log('✓ Example slides added');
150
+ console.log('✓ Demo image added to static/');
151
+ }
152
+ console.log();
153
+
154
+ // Запускаем npm install
155
+ console.log('Installing dependencies...');
156
+ const installResult = spawnSync('npm', ['install'], {
157
+ cwd: projectPath,
158
+ stdio: 'inherit',
159
+ });
160
+
161
+ if (installResult.status !== 0) {
162
+ console.error();
163
+ console.error('Failed to install dependencies.');
164
+ console.error('Please run "cd ' + projectName + ' && npm install" manually.');
165
+ process.exit(1);
166
+ }
69
167
 
70
- // Запускаем npm install
71
- console.log('Installing dependencies...');
72
- const installResult = spawnSync('npm', ['install'], {
73
- cwd: projectPath,
74
- stdio: 'inherit',
75
- });
168
+ console.log();
169
+ console.log(' Dependencies installed');
170
+ console.log();
171
+ console.log('Next steps:');
172
+ console.log(` cd ${projectName}`);
173
+ console.log(' npm run dev # Start live preview');
174
+ if (createExamples) {
175
+ console.log(' marp examples.md # Preview example slides');
176
+ }
177
+ console.log(' npm run build:all # Build all formats');
178
+ console.log();
76
179
 
77
- if (installResult.status !== 0) {
78
- console.error();
79
- console.error('Failed to install dependencies.');
80
- console.error('Please run "cd ' + projectName + ' && npm install" manually.');
180
+ } catch (err) {
181
+ console.error('Error creating project:', err.message);
81
182
  process.exit(1);
82
183
  }
83
-
84
- console.log();
85
- console.log('✓ Dependencies installed');
86
- console.log();
87
- console.log('Next steps:');
88
- console.log(` cd ${projectName}`);
89
- console.log(' npm run dev # Start live preview');
90
- console.log(' npm run build:all # Build all formats');
91
- console.log();
92
-
93
- } catch (err) {
94
- console.error('Error creating project:', err.message);
95
- process.exit(1);
96
- }
184
+ })();
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "create-marp-presentation",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Create a new Marp presentation project with one command",
5
5
  "bin": {
6
6
  "create-marp-presentation": "index.js"
7
7
  },
8
8
  "files": [
9
9
  "index.js",
10
- "template/"
10
+ "template/",
11
+ "template-optional/"
11
12
  ],
12
13
  "scripts": {
13
14
  "test": "jest"
@@ -1,39 +1,39 @@
1
1
  # Marp Presentation
2
2
 
3
- Шаблон для создания презентаций с Marp.
3
+ A template for creating presentations with Marp.
4
4
 
5
- ## Начало работы
5
+ ## Getting Started
6
6
 
7
- ### Live-предпросмотр
7
+ ### Live Preview
8
8
 
9
9
  ```bash
10
10
  npm run dev
11
11
  ```
12
12
 
13
- Откроется браузер с автообновлением при изменениях.
13
+ Opens a browser with auto-reload on changes.
14
14
 
15
- ### Создание слайдов
15
+ ### Creating Slides
16
16
 
17
- Редактируйте `presentation.md` — это главный файл презентации.
17
+ Edit `presentation.md` — this is the main presentation file.
18
18
 
19
- ## Сборка презентации
19
+ ## Building the Presentation
20
20
 
21
21
  ```bash
22
- npm run build:html # HTML презентация (интерактивная)
23
- npm run build:pdf # PDF файл
22
+ npm run build:html # HTML presentation (interactive)
23
+ npm run build:pdf # PDF file
24
24
  npm run build:pptx # PowerPoint
25
- npm run build:all # Все форматы сразу
25
+ npm run build:all # All formats at once
26
26
  ```
27
27
 
28
- Результат появится в папке `output/`.
28
+ The output will appear in the `output/` folder.
29
29
 
30
- ## Статические файлы
30
+ ## Static Files
31
31
 
32
- Поместите изображения и другие файлы в папку, указанную в `marp.config.js`.
32
+ Place images and other files in the folder specified in `marp.config.js`.
33
33
 
34
- По умолчанию: `static/`
34
+ Default: `static/`
35
35
 
36
- Вы можете добавить дополнительные папки в `marp.config.js`:
36
+ You can add additional folders in `marp.config.js`:
37
37
 
38
38
  ```javascript
39
39
  module.exports = {
@@ -42,15 +42,15 @@ module.exports = {
42
42
  };
43
43
  ```
44
44
 
45
- ## Очистка
45
+ ## Cleaning Up
46
46
 
47
47
  ```bash
48
48
  npm run clean
49
49
  ```
50
50
 
51
- Удаляет папку `output/`.
51
+ Removes the `output/` folder.
52
52
 
53
- ## Полезные ссылки
53
+ ## Useful Links
54
54
 
55
55
  - [Marp Documentation](https://marp.app/)
56
56
  - [Marp CLI](https://github.com/marp-team/marp-cli)
@@ -4,28 +4,28 @@ theme: default
4
4
  paginate: true
5
5
  ---
6
6
 
7
- # Моя презентация
7
+ # My Presentation
8
8
 
9
- Добро пожаловать в вашу новую Marp презентацию!
9
+ Welcome to your new Marp presentation!
10
10
 
11
11
  ---
12
12
 
13
- ## О Marp
13
+ ## About Marp
14
14
 
15
- Marp (Markdown Presentation Ecosystem) это инструмент для создания презентаций на Markdown.
15
+ Marp (Markdown Presentation Ecosystem) is a tool for creating presentations in Markdown.
16
16
 
17
17
  ---
18
18
 
19
- ## Возможности
19
+ ## Features
20
20
 
21
- - **Простой Markdown** - пишите слайды в привычном формате
22
- - **Темы** - используйте встроенные или создайте свою
23
- - **Экспорт** - HTML, PDF, PowerPoint
24
- - **Live preview** - мгновенный предпросмотр изменений
21
+ - **Simple Markdown** - write slides in a familiar format
22
+ - **Themes** - use built-in ones or create your own
23
+ - **Export** - HTML, PDF, PowerPoint
24
+ - **Live preview** - instant preview of changes
25
25
 
26
26
  ---
27
27
 
28
- ## Код с подсветкой
28
+ ## Code with Syntax Highlighting
29
29
 
30
30
  ```javascript
31
31
  function hello() {
@@ -35,9 +35,9 @@ function hello() {
35
35
 
36
36
  ---
37
37
 
38
- ## Изображения
38
+ ## Images
39
39
 
40
- Поместите изображения в папку `static/` и используйте их:
40
+ Place images in the `static/` folder and use them:
41
41
 
42
42
  ```
43
43
  ![alt text](static/image.png)
@@ -45,6 +45,6 @@ function hello() {
45
45
 
46
46
  ---
47
47
 
48
- # Вопросы?
48
+ # Questions?
49
49
 
50
- Документация: https://marp.app/
50
+ Documentation: https://marp.app/
File without changes
@@ -0,0 +1,249 @@
1
+ ---
2
+ marp: true
3
+ theme: default
4
+ paginate: true
5
+ math: katex
6
+ ---
7
+
8
+ # Marp Examples
9
+
10
+ Complete demonstration of Marp presentation capabilities
11
+
12
+ ---
13
+
14
+ ## Table of Contents
15
+
16
+ <!-- This auto-generates a table of contents -->
17
+ 1. [Basic Formatting](#basic-formatting)
18
+ 2. [Lists](#lists)
19
+ 3. [Quotes and Footnotes](#quotes-and-footnotes)
20
+ 4. [Code](#code)
21
+ 5. [Tables](#tables)
22
+ 6. [LaTeX Formulas](#latex-formulas)
23
+ 7. [Images](#images)
24
+ 8. [Multi-column Layouts](#multi-column-layouts)
25
+ 9. [Backgrounds and Styling](#backgrounds-and-styling)
26
+ 10. [Fragments (Animations)](#fragments-animations)
27
+
28
+ ---
29
+
30
+ ## Basic Formatting
31
+
32
+ ### Headings work like regular Markdown
33
+
34
+ This is **bold text** and this is *italic text*.
35
+
36
+ You can also use ~~strikethrough~~ and `inline code`.
37
+
38
+ ---
39
+
40
+ ## Lists
41
+
42
+ ### Unordered Lists
43
+
44
+ - First item
45
+ - Second item
46
+ - Nested item
47
+ - Another nested item
48
+ - Third item
49
+
50
+ ### Ordered Lists
51
+
52
+ 1. First step
53
+ 2. Second step
54
+ 3. Third step
55
+
56
+ ---
57
+
58
+ ## Quotes and Footnotes
59
+
60
+ > This is a blockquote.
61
+ > It can span multiple lines.
62
+ >
63
+ > — Author Name
64
+
65
+ Here's a sentence with a footnote[^1].
66
+
67
+ [^1]: This is the footnote content that appears at the bottom.
68
+
69
+ ---
70
+
71
+ ## Code
72
+
73
+ ### JavaScript
74
+
75
+ ```javascript
76
+ function greet(name) {
77
+ console.log(`Hello, ${name}!`);
78
+ }
79
+
80
+ greet('Marp');
81
+ ```
82
+
83
+ ### Python
84
+
85
+ ```python
86
+ def fibonacci(n):
87
+ if n <= 1:
88
+ return n
89
+ return fibonacci(n-1) + fibonacci(n-2)
90
+
91
+ print(fibonacci(10))
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Tables
97
+
98
+
99
+ ### Simple Table
100
+
101
+ | Feature | Status | Notes |
102
+ |---------|--------|-------|
103
+ | Markdown | Yes | Full support |
104
+ | Code blocks | Yes | Syntax highlighting |
105
+ | Images | Yes | Local and remote |
106
+ | Math | Yes | KaTeX support |
107
+
108
+ ---
109
+
110
+ ## Tables
111
+
112
+ ### Aligned Columns
113
+
114
+ | Left | Center | Right |
115
+ |:-----|:------:|------:|
116
+ | Default | Centered | Numbers |
117
+ | Text | Text | 1,234 |
118
+ | More | Data | 5,678 |
119
+
120
+
121
+
122
+ ---
123
+
124
+ ## LaTeX Formulas
125
+
126
+ ### Inline and Block Math
127
+
128
+ Inline formula: $E = mc^2$
129
+
130
+ Block formula:
131
+
132
+ $$
133
+ \int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
134
+ $$
135
+
136
+ ---
137
+ ## LaTeX Formulas
138
+
139
+ ### More Examples
140
+
141
+ Quadratic formula:
142
+
143
+ $$
144
+ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
145
+ $$
146
+
147
+ Matrix:
148
+
149
+ $$
150
+ \begin{pmatrix}
151
+ a & b \\
152
+ c & d
153
+ \end{pmatrix}
154
+ $$
155
+
156
+ ---
157
+
158
+ ## Images
159
+
160
+ ### Basic Image
161
+
162
+ ![Demo image](static/demo-image.png)
163
+
164
+ ---
165
+
166
+ ## Images
167
+
168
+ ### Sized Image
169
+
170
+ ![width:300px](static/demo-image.png)
171
+
172
+ ---
173
+
174
+ ## Multi-column Layouts
175
+
176
+ ### Using HTML Tables
177
+
178
+ <table>
179
+ <tr>
180
+ <td>
181
+
182
+ **Left Column**
183
+
184
+ - Point one
185
+ - Point two
186
+ - Point three
187
+
188
+ </td>
189
+ <td>
190
+
191
+ **Right Column**
192
+
193
+ - Another point
194
+ - More content
195
+ - Final item
196
+
197
+ </td>
198
+ </tr>
199
+ </table>
200
+
201
+ ---
202
+
203
+ ## Backgrounds and Styling
204
+
205
+ <!-- _backgroundColor: #1a1a2e -->
206
+ <!-- _color: #eaeaea -->
207
+
208
+ ### Dark Slide
209
+
210
+ This slide has a custom dark background and light text color.
211
+
212
+ You can use HTML color codes or named colors.
213
+
214
+ ---
215
+
216
+ <!-- _backgroundImage: url('static/demo-image.png') -->
217
+ <!-- _backgroundOpacity: 0.3 -->
218
+
219
+ ### Image Background
220
+
221
+ This slide has an image background with reduced opacity.
222
+
223
+ ---
224
+
225
+ ## Fragments (Animations)
226
+
227
+ Use asterisk `*` for incremental reveal:
228
+
229
+ * This appears first
230
+ * This appears second
231
+ * This appears third
232
+ * This appears last
233
+
234
+ Press space to reveal each item!
235
+
236
+ ---
237
+
238
+ <!-- _paginate: false -->
239
+
240
+ # Thank You!
241
+
242
+ ## Questions?
243
+
244
+ - GitHub: https://github.com/marp-team/marp
245
+ - Docs: https://marp.app/
246
+
247
+ ```
248
+ Contact: your-email@example.com
249
+ ```
File without changes