@adobe/helix-docx2md 1.0.14 → 1.0.17

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 CHANGED
@@ -1,3 +1,24 @@
1
+ ## [1.0.17](https://github.com/adobe/helix-docx2md/compare/v1.0.16...v1.0.17) (2022-05-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * keep softbreaks in headings ([#77](https://github.com/adobe/helix-docx2md/issues/77)) ([55695a4](https://github.com/adobe/helix-docx2md/commit/55695a4bfa93b35f81b41a4ecbd3f0244096f051))
7
+
8
+ ## [1.0.16](https://github.com/adobe/helix-docx2md/compare/v1.0.15...v1.0.16) (2022-05-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency @adobe/helix-markdown-support to v3.1.5 ([8800123](https://github.com/adobe/helix-docx2md/commit/8800123e8045a02083636ec23cb7802c673ced3d))
14
+
15
+ ## [1.0.15](https://github.com/adobe/helix-docx2md/compare/v1.0.14...v1.0.15) (2022-05-10)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * lists in consecutive rows ([#67](https://github.com/adobe/helix-docx2md/issues/67)) ([01a76e2](https://github.com/adobe/helix-docx2md/commit/01a76e2a47f1a51c2c23b42fa7d0d6d61705f1dd)), closes [#54](https://github.com/adobe/helix-docx2md/issues/54)
21
+
1
22
  ## [1.0.14](https://github.com/adobe/helix-docx2md/compare/v1.0.13...v1.0.14) (2022-05-10)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-docx2md",
3
- "version": "1.0.14",
3
+ "version": "1.0.17",
4
4
  "description": "Helix library that converts word documents to markdown",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "homepage": "https://github.com/adobe/helix-docx2md#readme",
36
36
  "dependencies": {
37
- "@adobe/helix-markdown-support": "3.1.4",
37
+ "@adobe/helix-markdown-support": "3.1.6",
38
38
  "@adobe/helix-shared-process-queue": "1.1.5",
39
39
  "@adobe/mammoth": "1.4.15-bleeding.1",
40
40
  "dirname-filename-esm": "1.1.1",
@@ -50,19 +50,18 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@adobe/eslint-config-helix": "1.3.2",
53
- "@adobe/helix-mediahandler": "1.0.22",
53
+ "@adobe/helix-mediahandler": "1.0.27",
54
54
  "@semantic-release/changelog": "6.0.1",
55
55
  "@semantic-release/exec": "6.0.3",
56
56
  "@semantic-release/git": "10.0.1",
57
- "c8": "7.11.2",
58
- "codecov": "3.8.3",
59
- "dotenv": "16.0.0",
60
- "eslint": "8.15.0",
57
+ "c8": "7.11.3",
58
+ "dotenv": "16.0.1",
59
+ "eslint": "8.16.0",
61
60
  "eslint-plugin-header": "3.1.1",
62
61
  "eslint-plugin-import": "2.26.0",
63
62
  "husky": "8.0.1",
64
63
  "junit-report-builder": "3.0.0",
65
- "lint-staged": "12.4.1",
64
+ "lint-staged": "12.4.2",
66
65
  "mocha": "10.0.0",
67
66
  "mocha-multi-reporters": "1.5.1",
68
67
  "semantic-release": "19.0.2",
@@ -15,6 +15,19 @@ import one from './one.js';
15
15
  import handlers from './handlers/index.js';
16
16
 
17
17
  /**
18
+ * @typedef {Node} List
19
+ *
20
+ * Stack of List entries (i.e. the <LI>s), where the last is the tail of the list
21
+ * @typedef {List[]} ListStack
22
+ *
23
+ * The containers for a list stack. eg the table-cell or just the document.
24
+ * This is to track the lists within the individual parents.
25
+ *
26
+ * Currently, we only create a new list container for the table-cell.
27
+ *
28
+ * Note: that the stack is reversed, i.e. the first is the deepest one.
29
+ * @typedef {ListStack[]} ListContainers
30
+ *
18
31
  * Converts the docx AST to markdown ast.
19
32
  * @param {object} tree the docx ast
20
33
  * @return {object} the markdown ast
@@ -45,8 +58,10 @@ export default async function dast2mdast(tree) {
45
58
  h.baseFound = false;
46
59
  h.frozenBaseUrl = null;
47
60
  h.handlers = handlers;
48
- h.lists = [];
49
61
  h.numbering = {};
50
62
 
63
+ /** @type {ListContainers} */
64
+ h.listContainers = [[]];
65
+
51
66
  return one(h, tree, null);
52
67
  }
@@ -81,6 +81,7 @@ export default function paragraph(h, node, parent, siblings) {
81
81
  }
82
82
 
83
83
  // check for list
84
+ const [lists] = h.listContainers;
84
85
  if (isListParagraph(node)) {
85
86
  const numbering = node.numbering || {};
86
87
  const { numId = 0, isOrdered = false, level = '0' } = numbering;
@@ -89,9 +90,9 @@ export default function paragraph(h, node, parent, siblings) {
89
90
 
90
91
  // find correct parent
91
92
  let tail;
92
- while (h.lists.length > 0) {
93
- tail = h.lists.pop();
94
- if (tail.ordered === isOrdered && h.lists.length <= lvl) {
93
+ while (lists.length > 0) {
94
+ tail = lists.pop();
95
+ if (tail.ordered === isOrdered && lists.length <= lvl) {
95
96
  break;
96
97
  }
97
98
  tail = null;
@@ -100,8 +101,8 @@ export default function paragraph(h, node, parent, siblings) {
100
101
  tail = h('list', { ordered: isOrdered, spread: false }, []);
101
102
  result = tail;
102
103
  }
103
- h.lists.push(tail);
104
- while (h.lists.length <= lvl) {
104
+ lists.push(tail);
105
+ while (lists.length <= lvl) {
105
106
  const newList = h('list', { ordered: isOrdered, spread: false }, []);
106
107
  if (tail.children.length > 0) {
107
108
  // append new list to end of the last list item
@@ -114,7 +115,7 @@ export default function paragraph(h, node, parent, siblings) {
114
115
  });
115
116
  }
116
117
  tail = newList;
117
- h.lists.push(tail);
118
+ lists.push(tail);
118
119
  }
119
120
  const listItem = {
120
121
  type: 'listItem',
@@ -147,7 +148,7 @@ export default function paragraph(h, node, parent, siblings) {
147
148
  }
148
149
  // clear lists list marker
149
150
  // eslint-disable-next-line no-param-reassign
150
- h.lists = [];
151
+ h.listContainers[0] = [];
151
152
 
152
153
  // check for heading
153
154
  let depth = getHeadingDepth(node);
@@ -166,7 +167,7 @@ export default function paragraph(h, node, parent, siblings) {
166
167
  return h('thematicBreak');
167
168
  }
168
169
  // sanitize children
169
- return h('heading', { depth }, nodes.filter((c) => (c.type !== 'break')));
170
+ return h('heading', { depth }, nodes);
170
171
  }
171
172
 
172
173
  // check for codeblock
@@ -23,5 +23,8 @@ export default function cell(h, node) {
23
23
  if (node.colSpan > 1) {
24
24
  props.colSpan = node.colSpan;
25
25
  }
26
- return h('tableCell', props, all(h, node));
26
+ h.listContainers.unshift([]);
27
+ const c = h('tableCell', props, all(h, node));
28
+ h.listContainers.shift();
29
+ return c;
27
30
  }