@helping-ai-workflow/md2doc 3.12.0 → 3.12.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.
@@ -1552,6 +1552,12 @@
1552
1552
  panels.say('已匯出 ' + exportName('svg'));
1553
1553
  }
1554
1554
 
1555
+ // PNG is rasterised at twice the SVG's own size: at 1x a 300-480px wide
1556
+ // diagram goes soft the moment it is pasted into a slide or shown on a
1557
+ // high-density screen (wave redesign spec section 5-7). The SVG is drawn
1558
+ // at the target size, so lines and text are re-rasterised, not upscaled.
1559
+ const PNG_SCALE = 2;
1560
+
1555
1561
  function exportPng() {
1556
1562
  const text = exportSvgText();
1557
1563
  if (text === '') { panels.say('預覽還沒畫出來,沒有東西可以匯出'); return; }
@@ -1568,14 +1574,14 @@
1568
1574
  const img = d.createElement('img');
1569
1575
  img.onload = function () {
1570
1576
  const cv = d.createElement('canvas');
1571
- cv.width = w; cv.height = h;
1577
+ cv.width = w * PNG_SCALE; cv.height = h * PNG_SCALE;
1572
1578
  const ctx2 = cv.getContext('2d');
1573
1579
  // The SVG's own background rect is white, but only over its own box;
1574
1580
  // painting white first means a PNG dropped into a dark-themed document
1575
1581
  // does not show that document's background through the margins.
1576
1582
  ctx2.fillStyle = '#ffffff';
1577
- ctx2.fillRect(0, 0, w, h);
1578
- ctx2.drawImage(img, 0, 0);
1583
+ ctx2.fillRect(0, 0, cv.width, cv.height);
1584
+ ctx2.drawImage(img, 0, 0, cv.width, cv.height);
1579
1585
  cv.toBlob(function (blob) {
1580
1586
  if (blob === null) { panels.say('PNG 轉檔失敗'); return; }
1581
1587
  downloadBlob(blob, exportName('png'));
@@ -259,6 +259,15 @@
259
259
  return 'hsl(' + Math.round(x[0]) + ', ' + Math.round(Math.min(x[1], smax) * 100) + '%, ' + Math.round(l * 100) + '%)';
260
260
  }
261
261
  function lineColour(c) { return hsl(c)[1] > 0.25 ? tone(c, 0.68, 0.8) : INK; }
262
+ // WaveDrom draws every edge label (and point note) as g > rect + text inside wavearcs_N, the
263
+ // white rect masking the edge and waveform behind the words. Made transparent like other
264
+ // near-white fills, the line runs straight through the text in dark; it takes the page
265
+ // colour instead. Only this shape: graphviz/mermaid white fills still go transparent.
266
+ function isWaveLabelBacking(el) {
267
+ var next = el.nextElementSibling;
268
+ return /^rect$/i.test(el.tagName) && next !== null && /^text$/i.test(next.tagName) &&
269
+ el.closest('[id^="wavearcs"]') !== null;
270
+ }
262
271
  function recolourSvg(svg, dark) {
263
272
  var els = svg.querySelectorAll('polygon, ellipse, path, polyline, rect, line, circle, text, tspan, foreignObject *');
264
273
  var live = svg.hasAttribute('data-md2doc-live');
@@ -305,7 +314,7 @@
305
314
  } else {
306
315
  if (fill && fill[3] > 0) {
307
316
  var L = lum(fill);
308
- if (L > 0.85) ov += 'fill:transparent !important;';
317
+ if (L > 0.85) ov += isWaveLabelBacking(el) ? 'fill:var(--md-bg) !important;' : 'fill:transparent !important;';
309
318
  else if (L > 0.3) ov += 'fill:' + tone(fill, 0.26, 0.55) + ' !important;';
310
319
  else if (el.closest('g.edge, marker')) ov += 'fill:' + lineColour(fill) + ' !important;';
311
320
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helping-ai-workflow/md2doc",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "description": "Markdown → HTML / PDF renderer with WaveDrom, Mermaid, Graphviz, and draw.io support",
5
5
  "keywords": [
6
6
  "markdown",