markdown-to-word 0.1.0 → 0.3.0

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/build/xml-part.js CHANGED
@@ -13,4 +13,65 @@ export function keepXmlDeclaration(original, serialized) {
13
13
  }
14
14
  return serialized;
15
15
  }
16
+ /** The children of `<w:pPr>`, in the order the schema requires. */
17
+ const PARAGRAPH_PROPERTY_ORDER = [
18
+ 'pStyle',
19
+ 'keepNext',
20
+ 'keepLines',
21
+ 'pageBreakBefore',
22
+ 'framePr',
23
+ 'widowControl',
24
+ 'numPr',
25
+ 'suppressLineNumbers',
26
+ 'pBdr',
27
+ 'shd',
28
+ 'tabs',
29
+ 'suppressAutoHyphens',
30
+ 'kinsoku',
31
+ 'wordWrap',
32
+ 'overflowPunct',
33
+ 'topLinePunct',
34
+ 'autoSpaceDE',
35
+ 'autoSpaceDN',
36
+ 'bidi',
37
+ 'adjustRightInd',
38
+ 'snapToGrid',
39
+ 'spacing',
40
+ 'ind',
41
+ 'contextualSpacing',
42
+ 'mirrorIndents',
43
+ 'suppressOverlap',
44
+ 'jc',
45
+ 'textDirection',
46
+ 'textAlignment',
47
+ 'textboxTightWrap',
48
+ 'outlineLvl',
49
+ 'divId',
50
+ 'cnfStyle',
51
+ 'rPr',
52
+ 'sectPr',
53
+ 'pPrChange',
54
+ ];
55
+ /**
56
+ * The `localName` child of a `<w:pPr>`, created in schema order if missing.
57
+ * WinWord rejects paragraph properties that are out of order.
58
+ */
59
+ export function paragraphProperty(pPr, localName) {
60
+ const rank = PARAGRAPH_PROPERTY_ORDER.indexOf(localName);
61
+ let before = null;
62
+ for (const child of Array.from(pPr.children)) {
63
+ if (child.namespaceURI !== WORDPROCESSING_NS) {
64
+ continue;
65
+ }
66
+ if (child.localName === localName) {
67
+ return child;
68
+ }
69
+ if (before === null &&
70
+ PARAGRAPH_PROPERTY_ORDER.indexOf(child.localName) > rank) {
71
+ before = child;
72
+ }
73
+ }
74
+ const created = pPr.ownerDocument.createElementNS(WORDPROCESSING_NS, `w:${localName}`);
75
+ return pPr.insertBefore(created, before);
76
+ }
16
77
  //# sourceMappingURL=xml-part.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xml-part.js","sourceRoot":"","sources":["../src/xml-part.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,8DAA8D,CAAC;AAEhG,4DAA4D;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAG,sCAAsC,CAAC;AAE7D;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,UAAkB;IACrE,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1D,IAAI,WAAW,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5D,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/** Namespace of the WordprocessingML parts inside a .docx. */\nexport const WORDPROCESSING_NS = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';\n\n/** Namespace of the `xml:` prefix, used for `xml:space`. */\nexport const XML_NS = 'http://www.w3.org/XML/1998/namespace';\n\n/**\n * `XMLSerializer` drops the XML declaration that OPC parts start with, so it is\n * copied back from the source.\n */\nexport function keepXmlDeclaration(original: string, serialized: string): string {\n const declaration = /^\\s*(<\\?xml[^>]*\\?>)/.exec(original);\n if (declaration && !serialized.trimStart().startsWith('<?')) {\n return `${declaration[1]}\\n${serialized}`;\n }\n return serialized;\n}\n"]}
1
+ {"version":3,"file":"xml-part.js","sourceRoot":"","sources":["../src/xml-part.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAC5B,8DAA8D,CAAC;AAEjE,4DAA4D;AA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AAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IACE,MAAM,KAAK,IAAI;YACf,wBAAwB,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,EACxD,CAAC;YACD,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,eAAe,CAC/C,iBAAiB,EACjB,KAAK,SAAS,EAAE,CACjB,CAAC;IACF,OAAO,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/** Namespace of the WordprocessingML parts inside a .docx. */\nexport const WORDPROCESSING_NS =\n 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';\n\n/** Namespace of the `xml:` prefix, used for `xml:space`. */\nexport const XML_NS = 'http://www.w3.org/XML/1998/namespace';\n\n/**\n * `XMLSerializer` drops the XML declaration that OPC parts start with, so it is\n * copied back from the source.\n */\nexport function keepXmlDeclaration(\n original: string,\n serialized: string\n): string {\n const declaration = /^\\s*(<\\?xml[^>]*\\?>)/.exec(original);\n if (declaration && !serialized.trimStart().startsWith('<?')) {\n return `${declaration[1]}\\n${serialized}`;\n }\n return serialized;\n}\n\n/** The children of `<w:pPr>`, in the order the schema requires. */\nconst PARAGRAPH_PROPERTY_ORDER = [\n 'pStyle',\n 'keepNext',\n 'keepLines',\n 'pageBreakBefore',\n 'framePr',\n 'widowControl',\n 'numPr',\n 'suppressLineNumbers',\n 'pBdr',\n 'shd',\n 'tabs',\n 'suppressAutoHyphens',\n 'kinsoku',\n 'wordWrap',\n 'overflowPunct',\n 'topLinePunct',\n 'autoSpaceDE',\n 'autoSpaceDN',\n 'bidi',\n 'adjustRightInd',\n 'snapToGrid',\n 'spacing',\n 'ind',\n 'contextualSpacing',\n 'mirrorIndents',\n 'suppressOverlap',\n 'jc',\n 'textDirection',\n 'textAlignment',\n 'textboxTightWrap',\n 'outlineLvl',\n 'divId',\n 'cnfStyle',\n 'rPr',\n 'sectPr',\n 'pPrChange',\n];\n\n/**\n * The `localName` child of a `<w:pPr>`, created in schema order if missing.\n * WinWord rejects paragraph properties that are out of order.\n */\nexport function paragraphProperty(pPr: Element, localName: string): Element {\n const rank = PARAGRAPH_PROPERTY_ORDER.indexOf(localName);\n let before: Element | null = null;\n for (const child of Array.from(pPr.children)) {\n if (child.namespaceURI !== WORDPROCESSING_NS) {\n continue;\n }\n if (child.localName === localName) {\n return child;\n }\n if (\n before === null &&\n PARAGRAPH_PROPERTY_ORDER.indexOf(child.localName) > rank\n ) {\n before = child;\n }\n }\n const created = pPr.ownerDocument.createElementNS(\n WORDPROCESSING_NS,\n `w:${localName}`\n );\n return pPr.insertBefore(created, before);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-to-word",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Convert GitHub Flavored Markdown to Word (.docx) documents in Node or the browser",
5
5
  "type": "module",
6
6
  "main": "build/main.js",
@@ -28,8 +28,10 @@
28
28
  "lint": "eslint .",
29
29
  "lint:fix": "eslint --fix .",
30
30
  "format": "prettier --write .",
31
+ "format:check": "prettier --check .",
31
32
  "typecheck": "astro sync && tsc --noEmit",
32
33
  "test": "vitest run",
34
+ "test:coverage": "vitest run --coverage",
33
35
  "test:e2e": "playwright test",
34
36
  "gen:og": "node scripts/gen-og.mjs",
35
37
  "gen:i18n": "node scripts/translate-i18n.mjs",
@@ -67,7 +69,8 @@
67
69
  "dompurify": "^3.4.17",
68
70
  "jsdom": "^30.1.3",
69
71
  "jszip": "^3.10.2",
70
- "marked": "^18.1.1"
72
+ "marked": "^18.1.1",
73
+ "marked-footnote": "^1.4.0"
71
74
  },
72
75
  "author": "Ben Balter <ben@balter.com>",
73
76
  "license": "MIT",
@@ -90,5 +93,10 @@
90
93
  ],
91
94
  "bugs": {
92
95
  "url": "https://github.com/benbalter/markdown-to-word-js/issues"
96
+ },
97
+ "overrides": {
98
+ "@tailwindcss/typography": {
99
+ "postcss-selector-parser": "^7.1.6"
100
+ }
93
101
  }
94
102
  }