@adobe/helix-docx2md 1.0.14 → 1.0.15
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,10 @@
|
|
|
1
|
+
## [1.0.15](https://github.com/adobe/helix-docx2md/compare/v1.0.14...v1.0.15) (2022-05-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 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)
|
|
7
|
+
|
|
1
8
|
## [1.0.14](https://github.com/adobe/helix-docx2md/compare/v1.0.13...v1.0.14) (2022-05-10)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -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 (
|
|
93
|
-
tail =
|
|
94
|
-
if (tail.ordered === isOrdered &&
|
|
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
|
-
|
|
104
|
-
while (
|
|
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
|
-
|
|
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.
|
|
151
|
+
h.listContainers[0] = [];
|
|
151
152
|
|
|
152
153
|
// check for heading
|
|
153
154
|
let depth = getHeadingDepth(node);
|
|
@@ -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
|
-
|
|
26
|
+
h.listContainers.unshift([]);
|
|
27
|
+
const c = h('tableCell', props, all(h, node));
|
|
28
|
+
h.listContainers.shift();
|
|
29
|
+
return c;
|
|
27
30
|
}
|