@bobfrankston/msger 0.1.343 → 0.1.345
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 +3 -0
- package/msger-native/bin/msgernative.exe +0 -0
- package/package.json +1 -1
- package/shower.js +16 -1
package/README.md
CHANGED
|
@@ -51,6 +51,9 @@ msger -html "<span style='color:red;background-color:yellow'>Alert!</span>"
|
|
|
51
51
|
msger -url "https://example.com"
|
|
52
52
|
msger -url "file:///path/to/page.html"
|
|
53
53
|
|
|
54
|
+
# Render a local markdown file (.md / .markdown auto-detected, no extension needed)
|
|
55
|
+
msger -url "file:///y:/notes/todo.md"
|
|
56
|
+
|
|
54
57
|
# Load URL with hash fragment
|
|
55
58
|
msger -url "https://example.com" -hash section1
|
|
56
59
|
msger -url "https://example.com" -hash "#intro"
|
|
Binary file
|
package/package.json
CHANGED
package/shower.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import { platform } from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { pathToFileURL } from 'url';
|
|
4
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import AnsiToHtml from 'ansi-to-html';
|
|
7
|
+
import { renderMarkdown, looksLikeMarkdown } from '@bobfrankston/msgcommon/markdown';
|
|
7
8
|
// Load package.json for version
|
|
8
9
|
import packageJson from './package.json' with { type: 'json' };
|
|
9
10
|
export class MessageBoxHandle {
|
|
@@ -380,6 +381,20 @@ function createMessageBoxHandle(options) {
|
|
|
380
381
|
// Debug logging (uncomment if needed)
|
|
381
382
|
// console.error(`[DEBUG] Path conversion: ${optionsToSend.url} → ${absolutePath} → ${fileUrl}`);
|
|
382
383
|
}
|
|
384
|
+
// Native markdown rendering: if URL is a local .md/.markdown file, render to a
|
|
385
|
+
// self-contained HTML document and rewrite the URL as a data: URL. wry's navigation
|
|
386
|
+
// handler explicitly allows data: URLs (see msger-native/src/main.rs).
|
|
387
|
+
if (optionsToSend.url && optionsToSend.url.startsWith('file:') && looksLikeMarkdown(optionsToSend.url)) {
|
|
388
|
+
try {
|
|
389
|
+
const localPath = fileURLToPath(optionsToSend.url);
|
|
390
|
+
const md = fs.readFileSync(localPath, 'utf-8');
|
|
391
|
+
const renderedHtml = renderMarkdown(md, path.basename(localPath));
|
|
392
|
+
optionsToSend.url = 'data:text/html;charset=utf-8;base64,' + Buffer.from(renderedHtml, 'utf-8').toString('base64');
|
|
393
|
+
}
|
|
394
|
+
catch (e) {
|
|
395
|
+
console.warn(`msger: markdown render failed for ${optionsToSend.url}: ${e.message} — falling back to raw load`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
383
398
|
// Append hash to URL if specified
|
|
384
399
|
if (optionsToSend.hash && optionsToSend.url) {
|
|
385
400
|
// Strip any existing hash from the base URL
|