@adobe/helix-docx2md 1.6.3 → 1.6.5
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 +14 -0
- package/package.json +12 -12
- package/src/dast2mdast/handlers/paragraph.js +23 -57
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.6.5](https://github.com/adobe/helix-docx2md/compare/v1.6.4...v1.6.5) (2024-08-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* ignore horizontal line marker in text ([#512](https://github.com/adobe/helix-docx2md/issues/512)) ([cf5defd](https://github.com/adobe/helix-docx2md/commit/cf5defde68f778f72b59906de4267105392285f1)), closes [#508](https://github.com/adobe/helix-docx2md/issues/508)
|
|
7
|
+
|
|
8
|
+
## [1.6.4](https://github.com/adobe/helix-docx2md/compare/v1.6.3...v1.6.4) (2024-07-13)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency dirname-filename-esm to v1.1.2 ([7e9b563](https://github.com/adobe/helix-docx2md/commit/7e9b563756d432939f2b41e35ed607324fde8828))
|
|
14
|
+
|
|
1
15
|
## [1.6.3](https://github.com/adobe/helix-docx2md/compare/v1.6.2...v1.6.3) (2024-07-04)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-docx2md",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Helix library that converts word documents to markdown",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/adobe/helix-docx2md#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@adobe/helix-markdown-support": "7.1.
|
|
37
|
+
"@adobe/helix-markdown-support": "7.1.4",
|
|
38
38
|
"@adobe/helix-shared-process-queue": "3.0.4",
|
|
39
39
|
"@adobe/mammoth": "1.7.1-bleeding.2",
|
|
40
40
|
"@adobe/mdast-util-gridtables": "4.0.6",
|
|
41
41
|
"@adobe/remark-gridtables": "3.0.6",
|
|
42
|
-
"dirname-filename-esm": "1.1.
|
|
42
|
+
"dirname-filename-esm": "1.1.2",
|
|
43
43
|
"github-slugger": "2.0.0",
|
|
44
44
|
"mdast-util-to-markdown": "2.1.0",
|
|
45
45
|
"mdast-util-to-string": "4.0.0",
|
|
@@ -53,23 +53,23 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@adobe/eslint-config-helix": "2.0.6",
|
|
56
|
-
"@adobe/helix-admin-support": "2.8.
|
|
57
|
-
"@adobe/helix-mediahandler": "2.5.
|
|
58
|
-
"@adobe/helix-onedrive-support": "11.
|
|
59
|
-
"@adobe/helix-shared-tokencache": "1.4.
|
|
56
|
+
"@adobe/helix-admin-support": "2.8.29",
|
|
57
|
+
"@adobe/helix-mediahandler": "2.5.17",
|
|
58
|
+
"@adobe/helix-onedrive-support": "11.5.10",
|
|
59
|
+
"@adobe/helix-shared-tokencache": "1.4.27",
|
|
60
60
|
"@semantic-release/changelog": "6.0.3",
|
|
61
61
|
"@semantic-release/exec": "6.0.3",
|
|
62
62
|
"@semantic-release/git": "10.0.1",
|
|
63
63
|
"c8": "10.1.2",
|
|
64
64
|
"dotenv": "16.4.5",
|
|
65
65
|
"eslint": "8.57.0",
|
|
66
|
-
"husky": "9.
|
|
67
|
-
"junit-report-builder": "
|
|
68
|
-
"lint-staged": "15.2.
|
|
69
|
-
"mocha": "10.
|
|
66
|
+
"husky": "9.1.4",
|
|
67
|
+
"junit-report-builder": "5.0.0",
|
|
68
|
+
"lint-staged": "15.2.8",
|
|
69
|
+
"mocha": "10.7.3",
|
|
70
70
|
"mocha-multi-reporters": "1.5.1",
|
|
71
71
|
"semantic-release": "24.0.0",
|
|
72
|
-
"unist-util-inspect": "8.
|
|
72
|
+
"unist-util-inspect": "8.1.0"
|
|
73
73
|
},
|
|
74
74
|
"lint-staged": {
|
|
75
75
|
"*.js": "eslint"
|
|
@@ -39,9 +39,15 @@ const HEADING_MAP = {
|
|
|
39
39
|
'heading 8': 8,
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Checks if the given nodes represent a horizontal line '---' or em dash character
|
|
44
|
+
*
|
|
45
|
+
* @param {Array} nodes - The nodes to check.
|
|
46
|
+
* @returns {boolean} - True if the nodes represent a horizontal line, false otherwise.
|
|
47
|
+
*/
|
|
42
48
|
function isHorizontalLine(nodes) {
|
|
43
49
|
const value = toString(nodes).trim();
|
|
44
|
-
return
|
|
50
|
+
return value === '---' || value === '\u2014';
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
function getHeadingDepth(node) {
|
|
@@ -265,6 +271,12 @@ export default function paragraph(h, node, parent, siblings) {
|
|
|
265
271
|
// eslint-disable-next-line no-param-reassign
|
|
266
272
|
h.listContainers[0] = [];
|
|
267
273
|
|
|
274
|
+
// check if no horizontal line in heading
|
|
275
|
+
if (isHorizontalLine(nodes)) {
|
|
276
|
+
ret.push(h('thematicBreak'));
|
|
277
|
+
return ret;
|
|
278
|
+
}
|
|
279
|
+
|
|
268
280
|
// check for heading
|
|
269
281
|
let depth = getHeadingDepth(node);
|
|
270
282
|
if (!depth) {
|
|
@@ -277,23 +289,18 @@ export default function paragraph(h, node, parent, siblings) {
|
|
|
277
289
|
}
|
|
278
290
|
|
|
279
291
|
if (depth) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// set the bookmark target to this heading and remove the child
|
|
290
|
-
child.bookmark.target = heading;
|
|
291
|
-
nodes.splice(idx, 1);
|
|
292
|
-
idx -= 1;
|
|
293
|
-
}
|
|
292
|
+
const heading = h('heading', { depth }, nodes);
|
|
293
|
+
// check bookmark children (could have multiple)
|
|
294
|
+
for (let idx = 0; idx < nodes.length; idx += 1) {
|
|
295
|
+
const child = nodes[idx];
|
|
296
|
+
if (child.type === 'bookmark') {
|
|
297
|
+
// set the bookmark target to this heading and remove the child
|
|
298
|
+
child.bookmark.target = heading;
|
|
299
|
+
nodes.splice(idx, 1);
|
|
300
|
+
idx -= 1;
|
|
294
301
|
}
|
|
295
|
-
ret.push(heading);
|
|
296
302
|
}
|
|
303
|
+
ret.push(heading);
|
|
297
304
|
handleBorder(node.border?.bottom, ret);
|
|
298
305
|
return ret;
|
|
299
306
|
}
|
|
@@ -323,47 +330,6 @@ export default function paragraph(h, node, parent, siblings) {
|
|
|
323
330
|
}
|
|
324
331
|
}
|
|
325
332
|
|
|
326
|
-
// check for thematicBreaks and frontmatter. they need to be block elements
|
|
327
|
-
let prevBreak;
|
|
328
|
-
let idx = nodes.findIndex(isHorizontalLine);
|
|
329
|
-
while (idx >= 0) {
|
|
330
|
-
const brk = h('thematicBreak');
|
|
331
|
-
// remove the nodes up until the horizontal line
|
|
332
|
-
const removed = nodes.splice(0, idx);
|
|
333
|
-
// if last element is a break, ignore it.
|
|
334
|
-
if (removed.length && removed[removed.length - 1].type === 'break') {
|
|
335
|
-
brk.breakBefore = true;
|
|
336
|
-
removed.pop();
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// remove the horizontal line
|
|
340
|
-
nodes.splice(0, 1);
|
|
341
|
-
|
|
342
|
-
// also check if element following is a break
|
|
343
|
-
if (nodes.length && nodes[0].type === 'break') {
|
|
344
|
-
brk.breakAfter = true;
|
|
345
|
-
nodes.splice(0, 1);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// if we had a previous thematic break, and all the text in between looks like yaml, then
|
|
349
|
-
// create a frontmatter block
|
|
350
|
-
if (prevBreak && prevBreak.breakAfter && brk.breakBefore) {
|
|
351
|
-
const src = toString({ children: removed });
|
|
352
|
-
prevBreak.type = 'yaml';
|
|
353
|
-
prevBreak.value = src;
|
|
354
|
-
prevBreak = null;
|
|
355
|
-
} else {
|
|
356
|
-
// else add the removed as a paragraph
|
|
357
|
-
if (removed.length) {
|
|
358
|
-
ret.push(h('paragraph', removed));
|
|
359
|
-
}
|
|
360
|
-
// and append the thematic break
|
|
361
|
-
ret.push(brk);
|
|
362
|
-
prevBreak = brk;
|
|
363
|
-
}
|
|
364
|
-
idx = nodes.findIndex(isHorizontalLine);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
333
|
// handle remaining nodes
|
|
368
334
|
if (nodes.length) {
|
|
369
335
|
// avoid paragraphs with just a break
|