mulmocast 1.2.25 → 1.2.26
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/lib/mcp/aaa.d.ts +2 -0
- package/lib/mcp/aaa.js +4 -0
- package/lib/mcp/server.js +1 -0
- package/lib/utils/markdown.js +10 -0
- package/package.json +1 -1
package/lib/mcp/aaa.d.ts
ADDED
package/lib/mcp/aaa.js
ADDED
package/lib/mcp/server.js
CHANGED
package/lib/utils/markdown.js
CHANGED
|
@@ -11,12 +11,22 @@ export const renderHTMLToImage = async (html, outputPath, width, height, isMerma
|
|
|
11
11
|
await page.setContent(html);
|
|
12
12
|
// Adjust page settings if needed (like width, height, etc.)
|
|
13
13
|
await page.setViewport({ width, height });
|
|
14
|
+
await page.addStyleTag({ content: "html,body{margin:0;padding:0;overflow:hidden}" });
|
|
14
15
|
if (isMermaid) {
|
|
15
16
|
await page.waitForFunction(() => {
|
|
16
17
|
const el = document.querySelector(".mermaid");
|
|
17
18
|
return el && el.dataset.ready === "true";
|
|
18
19
|
}, { timeout: 20000 });
|
|
19
20
|
}
|
|
21
|
+
// Measure the size of the page and scale the page to the width and height
|
|
22
|
+
await page.evaluate(({ vw, vh }) => {
|
|
23
|
+
const de = document.documentElement;
|
|
24
|
+
const sw = Math.max(de.scrollWidth, document.body.scrollWidth || 0);
|
|
25
|
+
const sh = Math.max(de.scrollHeight, document.body.scrollHeight || 0);
|
|
26
|
+
const scale = Math.min(vw / (sw || vw), vh / (sh || vh), 1); // <=1 で縮小のみ
|
|
27
|
+
de.style.overflow = "hidden";
|
|
28
|
+
document.body.style.zoom = String(scale);
|
|
29
|
+
}, { vw: width, vh: height });
|
|
20
30
|
// Step 3: Capture screenshot of the page (which contains the Markdown-rendered HTML)
|
|
21
31
|
await page.screenshot({ path: outputPath, omitBackground });
|
|
22
32
|
await browser.close();
|