@helping-ai-workflow/md2doc 1.1.1 → 1.1.2

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.
Files changed (2) hide show
  1. package/lib/md2doc.js +11 -1
  2. package/package.json +1 -1
package/lib/md2doc.js CHANGED
@@ -412,9 +412,19 @@ ${itemsHtml}
412
412
  marked.setOptions({ gfm: true, breaks: false, renderer });
413
413
 
414
414
  // Pre-process non-standard inline syntax before marked parses
415
+ const escAttr = (s) => String(s)
416
+ .replace(/&/g, '&')
417
+ .replace(/</g, '&lt;')
418
+ .replace(/>/g, '&gt;')
419
+ .replace(/"/g, '&quot;');
415
420
  const mdPre = md
416
421
  .replace(/\^([^^]+)\^/g, '<sup>$1</sup>') // ^a^ → <sup>a</sup>
417
- .replace(/~([^~]+)~/g, '<sub>$1</sub>'); // ~a~ → <sub>a</sub>
422
+ .replace(/~([^~]+)~/g, '<sub>$1</sub>') // ~a~ → <sub>a</sub>
423
+ .replace(/\[\[([^\]\n]+)\]\]/g, (_, inner) => { // [[ref-id, §sub]] → clickable citation
424
+ const body = inner.trim();
425
+ const slug = body.split(',', 1)[0].trim();
426
+ return `<a href="#${escAttr(slug)}">[${escAttr(body)}]</a>`;
427
+ });
418
428
 
419
429
  bodyHtml = marked.parse(mdPre);
420
430
  serializedSections = JSON.stringify(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helping-ai-workflow/md2doc",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Markdown → HTML / PDF renderer with WaveDrom, Mermaid, and Graphviz support",
5
5
  "keywords": [
6
6
  "markdown",