@adobe/helix-md2docx 1.3.11 → 1.4.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.
- package/CHANGELOG.md +21 -0
- package/package.json +4 -4
- package/src/mdast2docx/handlers/table.js +16 -8
- package/src/mdast2docx/handlers/tableCell.js +10 -1
- package/src/mdast2docx/handlers/tableRow.js +2 -7
- package/src/mdast2docx/hast-table-handler.js +3 -3
- package/src/mdast2docx/template/[Content_Types].xml +39 -41
- package/src/mdast2docx/template/docProps/app.xml +40 -20
- package/src/mdast2docx/template/docProps/core.xml +12 -12
- package/src/mdast2docx/template/word/_rels/document.xml.rels +36 -51
- package/src/mdast2docx/template/word/document.xml +1907 -1116
- package/src/mdast2docx/template/word/fontTable.xml +105 -58
- package/src/mdast2docx/template/word/media/image1.png +0 -0
- package/src/mdast2docx/template/word/numbering.xml +622 -277
- package/src/mdast2docx/template/word/settings.xml +140 -91
- package/src/mdast2docx/template/word/styles.xml +1815 -1084
- package/src/mdast2docx/template/word/theme/theme1.xml +490 -296
- package/src/mdast2docx/template/word/webSettings.xml +13 -40
- package/src/mdast2docx/template.docx +0 -0
- package/src/mdast2docx/template/word/_rels/settings.xml.rels +0 -7
- package/src/mdast2docx/template/word/endnotes.xml +0 -56
- package/src/mdast2docx/template/word/footer1.xml +0 -39
- package/src/mdast2docx/template/word/footer2.xml +0 -39
- package/src/mdast2docx/template/word/footer3.xml +0 -39
- package/src/mdast2docx/template/word/footnotes.xml +0 -56
- package/src/mdast2docx/template/word/header1.xml +0 -39
- package/src/mdast2docx/template/word/header2.xml +0 -39
- package/src/mdast2docx/template/word/header3.xml +0 -39
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [1.4.2](https://github.com/adobe/helix-md2docx/compare/v1.4.1...v1.4.2) (2022-04-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update adobe fixes ([#55](https://github.com/adobe/helix-md2docx/issues/55)) ([dc33fdc](https://github.com/adobe/helix-md2docx/commit/dc33fdcb4b55f4cc8aaf44be99f81bf9f8918fd1))
|
|
7
|
+
|
|
8
|
+
## [1.4.1](https://github.com/adobe/helix-md2docx/compare/v1.4.0...v1.4.1) (2022-03-24)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* link style ([2711009](https://github.com/adobe/helix-md2docx/commit/2711009ba525024bedd65361fd62dae1f0432fdb))
|
|
14
|
+
|
|
15
|
+
# [1.4.0](https://github.com/adobe/helix-md2docx/compare/v1.3.11...v1.4.0) (2022-03-24)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* new docx template ([e8a96b7](https://github.com/adobe/helix-md2docx/commit/e8a96b7035d1c6c804bf9c3c8b748c432e1f5421))
|
|
21
|
+
|
|
1
22
|
## [1.3.11](https://github.com/adobe/helix-md2docx/compare/v1.3.10...v1.3.11) (2022-03-24)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-md2docx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Helix Service that converts markdown to word documents",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/adobe/helix-md2docx#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@adobe/helix-fetch": "3.0.
|
|
30
|
+
"@adobe/helix-fetch": "3.0.8",
|
|
31
31
|
"@adobe/helix-markdown-support": "3.1.2",
|
|
32
32
|
"@adobe/helix-shared-process-queue": "1.1.4",
|
|
33
33
|
"@adobe/helix-docx2md": "1.0.10",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@adobe/eslint-config-helix": "1.3.2",
|
|
46
|
-
"@adobe/helix-mediahandler": "1.0.
|
|
46
|
+
"@adobe/helix-mediahandler": "1.0.16",
|
|
47
47
|
"@semantic-release/changelog": "6.0.1",
|
|
48
48
|
"@semantic-release/exec": "6.0.3",
|
|
49
49
|
"@semantic-release/git": "10.0.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"chai": "4.3.6",
|
|
52
52
|
"codecov": "3.8.3",
|
|
53
53
|
"dotenv": "16.0.0",
|
|
54
|
-
"eslint": "8.
|
|
54
|
+
"eslint": "8.12.0",
|
|
55
55
|
"eslint-plugin-header": "3.1.1",
|
|
56
56
|
"eslint-plugin-import": "2.25.4",
|
|
57
57
|
"fs-extra": "10.0.1",
|
|
@@ -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
|
|
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
|
|
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
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
</
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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>
|