@adobe/helix-md2docx 1.3.11 → 1.4.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.
Files changed (28) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/src/mdast2docx/handlers/table.js +16 -8
  4. package/src/mdast2docx/handlers/tableCell.js +10 -1
  5. package/src/mdast2docx/handlers/tableRow.js +2 -7
  6. package/src/mdast2docx/hast-table-handler.js +3 -3
  7. package/src/mdast2docx/template/[Content_Types].xml +39 -41
  8. package/src/mdast2docx/template/docProps/app.xml +40 -20
  9. package/src/mdast2docx/template/docProps/core.xml +12 -12
  10. package/src/mdast2docx/template/word/_rels/document.xml.rels +36 -51
  11. package/src/mdast2docx/template/word/document.xml +1907 -1116
  12. package/src/mdast2docx/template/word/fontTable.xml +105 -58
  13. package/src/mdast2docx/template/word/media/image1.png +0 -0
  14. package/src/mdast2docx/template/word/numbering.xml +622 -277
  15. package/src/mdast2docx/template/word/settings.xml +140 -91
  16. package/src/mdast2docx/template/word/styles.xml +1806 -1084
  17. package/src/mdast2docx/template/word/theme/theme1.xml +490 -296
  18. package/src/mdast2docx/template/word/webSettings.xml +13 -40
  19. package/src/mdast2docx/template.docx +0 -0
  20. package/src/mdast2docx/template/word/_rels/settings.xml.rels +0 -7
  21. package/src/mdast2docx/template/word/endnotes.xml +0 -56
  22. package/src/mdast2docx/template/word/footer1.xml +0 -39
  23. package/src/mdast2docx/template/word/footer2.xml +0 -39
  24. package/src/mdast2docx/template/word/footer3.xml +0 -39
  25. package/src/mdast2docx/template/word/footnotes.xml +0 -56
  26. package/src/mdast2docx/template/word/header1.xml +0 -39
  27. package/src/mdast2docx/template/word/header2.xml +0 -39
  28. package/src/mdast2docx/template/word/header3.xml +0 -39
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.4.0](https://github.com/adobe/helix-md2docx/compare/v1.3.11...v1.4.0) (2022-03-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * new docx template ([e8a96b7](https://github.com/adobe/helix-md2docx/commit/e8a96b7035d1c6c804bf9c3c8b748c432e1f5421))
7
+
1
8
  ## [1.3.11](https://github.com/adobe/helix-md2docx/compare/v1.3.10...v1.3.11) (2022-03-24)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2docx",
3
- "version": "1.3.11",
3
+ "version": "1.4.0",
4
4
  "description": "Helix Service that converts markdown to word documents",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -21,24 +21,32 @@ const { Paragraph, Table, WidthType } = docx;
21
21
  // decimal or a percent, so a % symbol should be included when type="pct".
22
22
 
23
23
  export default async function table(ctx, node) {
24
+ let numCols = node.maxCols;
25
+ if (node.children.length > 0) {
26
+ // eslint-disable-next-line no-param-reassign
27
+ node.children[0].tableHeader = true;
28
+ if (!numCols) {
29
+ numCols = node.children[0].children.length;
30
+ }
31
+ }
32
+
24
33
  const oldTable = ctx.table;
25
34
  ctx.table = {
26
- // remember the table width (the column width will be calculated in the tableRow handler)
35
+ // remember the table width
27
36
  // default width: Letter Width - Margin = 8.5" - 2" = 6.5". the unit is 1/1440 inches.
28
- width: oldTable ? oldTable.columnWidth : 1440 * 6.5,
37
+ width: oldTable?.columnWidth || 1440 * 6.5,
29
38
  align: node.align || [],
30
39
  };
40
+
41
+ // use the same width for all columns
42
+ ctx.table.columnWidth = numCols ? (ctx.table.width / numCols) : ctx.table.width;
43
+ const columnWidths = new Array(numCols).fill(Math.round(ctx.table.columnWidth));
44
+
31
45
  // process the rows
32
46
  const rows = await all(ctx, node);
33
47
 
34
- // and remember the column width
35
- const { columnWidth } = ctx.table;
36
48
  ctx.table = oldTable;
37
49
 
38
- // use the same width for all columns
39
- const numCols = rows.length ? rows[0].CellCount : 0;
40
- const columnWidths = new Array(numCols).fill(Math.round(columnWidth));
41
-
42
50
  const tbl = new Table({
43
51
  style: 'PageBlock',
44
52
  rows,
@@ -13,7 +13,7 @@ import docx from 'docx';
13
13
  import all from '../all.js';
14
14
 
15
15
  const {
16
- AlignmentType, Paragraph, Table, TableCell,
16
+ AlignmentType, Paragraph, Table, TableCell, ShadingType,
17
17
  } = docx;
18
18
 
19
19
  const ALIGN = {
@@ -55,5 +55,14 @@ export default async function tableCell(ctx, node, parent, siblings) {
55
55
  if (node.data?.rowSpan) {
56
56
  opts.rowSpan = node.data.rowSpan;
57
57
  }
58
+
59
+ if (parent.tableHeader) {
60
+ // shading for header row
61
+ opts.shading = {
62
+ fill: 'F4CCCD', // color defined in styles.xml (PageBlock table style)
63
+ type: ShadingType.CLEAR,
64
+ color: 'auto',
65
+ };
66
+ }
58
67
  return new TableCell(opts);
59
68
  }
@@ -14,15 +14,10 @@ import all from '../all.js';
14
14
 
15
15
  const { TableRow } = docx;
16
16
 
17
- export default async function tableRow(ctx, node, parent, siblings) {
18
- // adjust columnWidth
19
- if (!ctx.table.columnWidth) {
20
- ctx.table.columnWidth = ctx.table.width / node.children.length;
21
- }
22
-
17
+ export default async function tableRow(ctx, node) {
23
18
  const children = await all(ctx, node);
24
19
  return new TableRow({
25
20
  children,
26
- tableHeader: siblings.length === 0,
21
+ // tableHeader: node.tableHeader,
27
22
  });
28
23
  }
@@ -94,7 +94,7 @@ export default function table(h, node) {
94
94
  mdNode.align = [];
95
95
 
96
96
  // compute the number of cells in each row, respecting the row and col spans.
97
- let maxCols = 0;
97
+ mdNode.maxCols = 0;
98
98
  const pendingRowSpans = [];
99
99
  for (const row of mdNode.children) {
100
100
  row.numCols = pendingRowSpans.shift() || 0;
@@ -111,12 +111,12 @@ export default function table(h, node) {
111
111
  }
112
112
  }
113
113
  }
114
- maxCols = Math.max(maxCols, row.numCols);
114
+ mdNode.maxCols = Math.max(mdNode.maxCols, row.numCols);
115
115
  }
116
116
 
117
117
  // add empty cells if needed
118
118
  for (const row of mdNode.children) {
119
- for (let i = row.numCols; i < maxCols; i += 1) {
119
+ for (let i = row.numCols; i < mdNode.maxCols; i += 1) {
120
120
  row.children.push({ type: 'tableCell', children: [] });
121
121
  }
122
122
  delete row.numCols;
@@ -1,41 +1,39 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
- <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
3
- <Default Extension="png" ContentType="image/png"/>
4
- <Default Extension="rels"
5
- ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
6
- <Default Extension="xml" ContentType="application/xml"/>
7
- <Override PartName="/word/document.xml"
8
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
9
- <Override PartName="/word/numbering.xml"
10
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>
11
- <Override PartName="/word/styles.xml"
12
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
13
- <Override PartName="/word/settings.xml"
14
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>
15
- <Override PartName="/word/webSettings.xml"
16
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"/>
17
- <Override PartName="/word/footnotes.xml"
18
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>
19
- <Override PartName="/word/endnotes.xml"
20
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"/>
21
- <Override PartName="/word/header1.xml"
22
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"/>
23
- <Override PartName="/word/header2.xml"
24
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"/>
25
- <Override PartName="/word/footer1.xml"
26
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"/>
27
- <Override PartName="/word/footer2.xml"
28
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"/>
29
- <Override PartName="/word/header3.xml"
30
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"/>
31
- <Override PartName="/word/footer3.xml"
32
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"/>
33
- <Override PartName="/word/fontTable.xml"
34
- ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/>
35
- <Override PartName="/word/theme/theme1.xml"
36
- ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
37
- <Override PartName="/docProps/core.xml"
38
- ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
39
- <Override PartName="/docProps/app.xml"
40
- ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
41
- </Types>
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
3
+ <Default
4
+ Extension="png"
5
+ ContentType="image/png"/>
6
+ <Default
7
+ Extension="rels"
8
+ ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
9
+ <Default
10
+ Extension="xml"
11
+ ContentType="application/xml"/>
12
+ <Override
13
+ PartName="/word/document.xml"
14
+ ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
15
+ <Override
16
+ PartName="/word/numbering.xml"
17
+ ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>
18
+ <Override
19
+ PartName="/word/styles.xml"
20
+ ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
21
+ <Override
22
+ PartName="/word/settings.xml"
23
+ ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>
24
+ <Override
25
+ PartName="/word/webSettings.xml"
26
+ ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"/>
27
+ <Override
28
+ PartName="/word/fontTable.xml"
29
+ ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/>
30
+ <Override
31
+ PartName="/word/theme/theme1.xml"
32
+ ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
33
+ <Override
34
+ PartName="/docProps/core.xml"
35
+ ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
36
+ <Override
37
+ PartName="/docProps/app.xml"
38
+ ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
39
+ </Types>
@@ -1,20 +1,40 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
- <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
3
- xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
4
- <Template>template.dotx</Template>
5
- <TotalTime>6</TotalTime>
6
- <Pages>2</Pages>
7
- <Words>222</Words>
8
- <Characters>1266</Characters>
9
- <Application>Microsoft Office Word</Application>
10
- <DocSecurity>0</DocSecurity>
11
- <Lines>10</Lines>
12
- <Paragraphs>2</Paragraphs>
13
- <ScaleCrop>false</ScaleCrop>
14
- <Company></Company>
15
- <LinksUpToDate>false</LinksUpToDate>
16
- <CharactersWithSpaces>1486</CharactersWithSpaces>
17
- <SharedDoc>false</SharedDoc>
18
- <HyperlinksChanged>false</HyperlinksChanged>
19
- <AppVersion>16.0000</AppVersion>
20
- </Properties>
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Properties
3
+ xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
4
+ xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
5
+ <Template>Normal.dotm</Template>
6
+ <TotalTime>51</TotalTime>
7
+ <Pages>3</Pages>
8
+ <Words>271</Words>
9
+ <Characters>1545</Characters>
10
+ <Application>Microsoft Office Word</Application>
11
+ <DocSecurity>0</DocSecurity>
12
+ <Lines>12</Lines>
13
+ <Paragraphs>3</Paragraphs>
14
+ <ScaleCrop>false</ScaleCrop>
15
+ <HeadingPairs>
16
+ <vt:vector
17
+ size="2"
18
+ baseType="variant">
19
+ <vt:variant>
20
+ <vt:lpstr>Title</vt:lpstr>
21
+ </vt:variant>
22
+ <vt:variant>
23
+ <vt:i4>1</vt:i4>
24
+ </vt:variant>
25
+ </vt:vector>
26
+ </HeadingPairs>
27
+ <TitlesOfParts>
28
+ <vt:vector
29
+ size="1"
30
+ baseType="lpstr">
31
+ <vt:lpstr></vt:lpstr>
32
+ </vt:vector>
33
+ </TitlesOfParts>
34
+ <Company></Company>
35
+ <LinksUpToDate>false</LinksUpToDate>
36
+ <CharactersWithSpaces>1813</CharactersWithSpaces>
37
+ <SharedDoc>false</SharedDoc>
38
+ <HyperlinksChanged>false</HyperlinksChanged>
39
+ <AppVersion>16.0000</AppVersion>
40
+ </Properties>
@@ -1,12 +1,12 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
- <cp:coreProperties
3
- xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
4
- xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
5
- xmlns:dcmitype="http://purl.org/dc/dcmitype/"
6
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
7
- <dc:creator>Tobias Bocanegra</dc:creator>
8
- <cp:lastModifiedBy>Tobias Bocanegra</cp:lastModifiedBy>
9
- <cp:revision>3</cp:revision>
10
- <dcterms:created xsi:type="dcterms:W3CDTF">2021-03-19T03:32:00Z</dcterms:created>
11
- <dcterms:modified xsi:type="dcterms:W3CDTF">2021-04-02T02:45:00Z</dcterms:modified>
12
- </cp:coreProperties>
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <cp:coreProperties
3
+ xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
4
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
5
+ xmlns:dcterms="http://purl.org/dc/terms/"
6
+ xmlns:dcmitype="http://purl.org/dc/dcmitype/"
7
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
8
+ <cp:lastModifiedBy>Alexandre Capt</cp:lastModifiedBy>
9
+ <cp:revision>29</cp:revision>
10
+ <dcterms:created xsi:type="dcterms:W3CDTF">2022-03-23T14:16:00Z</dcterms:created>
11
+ <dcterms:modified xsi:type="dcterms:W3CDTF">2022-03-24T09:17:00Z</dcterms:modified>
12
+ </cp:coreProperties>
@@ -1,51 +1,36 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
3
- <Relationship Id="rId8"
4
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
5
- Target="media/image1.png"/>
6
- <Relationship Id="rId13"
7
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
8
- Target="header3.xml"/>
9
- <Relationship Id="rId3"
10
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"
11
- Target="settings.xml"/>
12
- <Relationship Id="rId7"
13
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
14
- Target="https://www.adobe.com/" TargetMode="External"/>
15
- <Relationship Id="rId12"
16
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
17
- Target="footer2.xml"/>
18
- <Relationship Id="rId2"
19
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
20
- Target="styles.xml"/>
21
- <Relationship Id="rId16"
22
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
23
- Target="theme/theme1.xml"/>
24
- <Relationship Id="rId1"
25
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"
26
- Target="numbering.xml"/>
27
- <Relationship Id="rId6"
28
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"
29
- Target="endnotes.xml"/>
30
- <Relationship Id="rId11"
31
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
32
- Target="footer1.xml"/>
33
- <Relationship Id="rId5"
34
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
35
- Target="footnotes.xml"/>
36
- <Relationship Id="rId15"
37
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
38
- Target="fontTable.xml"/>
39
- <Relationship Id="rId10"
40
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
41
- Target="header2.xml"/>
42
- <Relationship Id="rId4"
43
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"
44
- Target="webSettings.xml"/>
45
- <Relationship Id="rId9"
46
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
47
- Target="header1.xml"/>
48
- <Relationship Id="rId14"
49
- Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
50
- Target="footer3.xml"/>
51
- </Relationships>
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
3
+ <Relationship
4
+ Id="rId8"
5
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
6
+ Target="theme/theme1.xml"/>
7
+ <Relationship
8
+ Id="rId3"
9
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"
10
+ Target="settings.xml"/>
11
+ <Relationship
12
+ Id="rId7"
13
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
14
+ Target="fontTable.xml"/>
15
+ <Relationship
16
+ Id="rId2"
17
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
18
+ Target="styles.xml"/>
19
+ <Relationship
20
+ Id="rId1"
21
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"
22
+ Target="numbering.xml"/>
23
+ <Relationship
24
+ Id="rId6"
25
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
26
+ Target="media/image1.png"/>
27
+ <Relationship
28
+ Id="rId5"
29
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
30
+ Target="https://www.adobe.com/"
31
+ TargetMode="External"/>
32
+ <Relationship
33
+ Id="rId4"
34
+ Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"
35
+ Target="webSettings.xml"/>
36
+ </Relationships>