mdv-live 0.3.0 → 0.3.1

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
@@ -87,7 +87,7 @@ macOSで`.md`ファイルをダブルクリックしてMDVで開けるように
87
87
  which mdv
88
88
 
89
89
  # セットアップスクリプトを実行
90
- curl -fsSL https://raw.githubusercontent.com/panhouse/mdv/main/scripts/setup-macos-app.sh | bash
90
+ curl -fsSL https://raw.githubusercontent.com/panhouse/mdv-live/main/scripts/setup-macos-app.sh | bash
91
91
  ```
92
92
 
93
93
  または、リポジトリをクローンしている場合:
@@ -175,8 +175,8 @@ paginate: true
175
175
 
176
176
  ```bash
177
177
  # Clone repository
178
- git clone https://github.com/panhouse/mdv.git
179
- cd mdv
178
+ git clone https://github.com/panhouse/mdv-live.git
179
+ cd mdv-live
180
180
 
181
181
  # Install dependencies
182
182
  npm install
package/README.pdf ADDED
Binary file
package/bin/mdv.js CHANGED
@@ -212,7 +212,17 @@ function killServers(target, killAll) {
212
212
  }
213
213
 
214
214
  /**
215
- * Convert markdown to PDF using marp-cli
215
+ * Check if markdown content is a Marp presentation
216
+ */
217
+ function isMarpFile(content) {
218
+ const MARP_PATTERN = /^---\s*\n[\s\S]*?marp:\s*true[\s\S]*?\n---/;
219
+ return MARP_PATTERN.test(content);
220
+ }
221
+
222
+ /**
223
+ * Convert markdown to PDF
224
+ * - Marp slides: use marp-cli
225
+ * - Regular markdown: use marp-cli with document-like settings
216
226
  */
217
227
  async function convertToPdf(inputPath, outputPath) {
218
228
  const resolved = path.resolve(inputPath);
@@ -230,23 +240,51 @@ async function convertToPdf(inputPath, outputPath) {
230
240
  return 1;
231
241
  }
232
242
 
243
+ const content = await fs.readFile(resolved, 'utf-8');
244
+ const isMarp = isMarpFile(content);
245
+
233
246
  const defaultOutput = resolved.replace(/\.(md|markdown)$/i, '.pdf');
234
247
  const finalOutput = outputPath ? path.resolve(outputPath) : defaultOutput;
235
248
 
236
249
  console.log(`Converting ${inputPath} to PDF...`);
237
250
 
238
- try {
239
- // Use marp-cli for PDF conversion (supports Marp slides)
240
- execSync(`npx @marp-team/marp-cli "${resolved}" --pdf -o "${finalOutput}"`, {
241
- encoding: 'utf-8',
242
- stdio: 'inherit'
243
- });
244
- console.log(`PDF saved: ${finalOutput}`);
245
- return 0;
246
- } catch (err) {
247
- console.error('Error: PDF conversion failed');
248
- console.error('Make sure Node.js and npx are installed');
249
- return 1;
251
+ if (isMarp) {
252
+ // Marp slide: use marp-cli directly
253
+ try {
254
+ execSync(`npx @marp-team/marp-cli --no-stdin "${resolved}" --pdf -o "${finalOutput}"`, {
255
+ encoding: 'utf-8',
256
+ stdio: 'inherit'
257
+ });
258
+ console.log(`PDF saved: ${finalOutput}`);
259
+ return 0;
260
+ } catch (err) {
261
+ console.error('Error: PDF conversion failed');
262
+ return 1;
263
+ }
264
+ } else {
265
+ // Regular markdown: use md-to-pdf for proper A4 document format
266
+ console.log('Converting as document (A4 portrait)...');
267
+
268
+ try {
269
+ execSync(`npx md-to-pdf "${resolved}" --pdf-options '{"format":"A4","margin":{"top":"20mm","right":"20mm","bottom":"20mm","left":"20mm"}}'`, {
270
+ encoding: 'utf-8',
271
+ stdio: 'inherit',
272
+ cwd: path.dirname(resolved)
273
+ });
274
+
275
+ // md-to-pdf outputs to same directory with .pdf extension
276
+ const generatedPdf = resolved.replace(/\.(md|markdown)$/i, '.pdf');
277
+ if (generatedPdf !== finalOutput) {
278
+ await fs.rename(generatedPdf, finalOutput);
279
+ }
280
+
281
+ console.log(`PDF saved: ${finalOutput}`);
282
+ return 0;
283
+ } catch (err) {
284
+ console.error('Error: PDF conversion failed');
285
+ console.error('Make sure md-to-pdf is available (npx md-to-pdf)');
286
+ return 1;
287
+ }
250
288
  }
251
289
  }
252
290
 
@@ -361,7 +399,7 @@ async function main() {
361
399
 
362
400
  // Version
363
401
  if (values.version) {
364
- console.log('mdv v0.3.0');
402
+ console.log('mdv v0.3.1');
365
403
  process.exit(0);
366
404
  }
367
405
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdv-live",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Markdown Viewer - File tree + Live preview + Marp support + Hot reload",
5
5
  "main": "src/server.js",
6
6
  "bin": {
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "git+https://github.com/panhouse/mdv.git"
33
+ "url": "git+https://github.com/panhouse/mdv-live.git"
34
34
  },
35
- "homepage": "https://github.com/panhouse/mdv#readme",
35
+ "homepage": "https://github.com/panhouse/mdv-live#readme",
36
36
  "bugs": {
37
- "url": "https://github.com/panhouse/mdv/issues"
37
+ "url": "https://github.com/panhouse/mdv-live/issues"
38
38
  },
39
39
  "files": [
40
40
  "bin/",
@@ -43,7 +43,7 @@ Usage:
43
43
  - Double-click any .md file
44
44
  - Drag & drop .md files onto this app
45
45
 
46
- Version: 0.3.0 (Node.js)" buttons {"OK"} default button "OK" with title "MDV"
46
+ Version: 0.3.1 (Node.js)" buttons {"OK"} default button "OK" with title "MDV"
47
47
  end run
48
48
  EOF
49
49
 
@@ -127,9 +127,9 @@ cat << 'EOF' > "$TEMP_DIR/$APP_NAME/Contents/Info.plist"
127
127
  <key>CFBundlePackageType</key>
128
128
  <string>APPL</string>
129
129
  <key>CFBundleShortVersionString</key>
130
- <string>0.3.0</string>
130
+ <string>0.3.1</string>
131
131
  <key>CFBundleVersion</key>
132
- <string>0.3.0</string>
132
+ <string>0.3.1</string>
133
133
  <key>LSMinimumSystemVersion</key>
134
134
  <string>10.13</string>
135
135
  </dict>
package/src/server.js CHANGED
@@ -51,7 +51,7 @@ export function createMdvServer(options) {
51
51
  app.get('/api/info', (req, res) => {
52
52
  res.json({
53
53
  rootPath: app.locals.rootDir,
54
- version: '0.3.0'
54
+ version: '0.3.1'
55
55
  });
56
56
  });
57
57