@adobe/helix-docx2md 1.4.20 → 1.5.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.
- package/CHANGELOG.md +14 -0
- package/package.json +11 -11
- package/src/dast2mdast/handlers/paragraph.js +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.5.0](https://github.com/adobe/helix-docx2md/compare/v1.4.21...v1.5.0) (2023-11-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Handle emdash character for section breaks ([c2c8495](https://github.com/adobe/helix-docx2md/commit/c2c84957bf7a8f47acf70035d08318f84ea12de8)), closes [#343](https://github.com/adobe/helix-docx2md/issues/343)
|
|
7
|
+
|
|
8
|
+
## [1.4.21](https://github.com/adobe/helix-docx2md/compare/v1.4.20...v1.4.21) (2023-10-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency unified to v11.0.4 ([#337](https://github.com/adobe/helix-docx2md/issues/337)) ([bb749d8](https://github.com/adobe/helix-docx2md/commit/bb749d8e1b435d0e5a8a707ab8e00cdbcd5fdf79))
|
|
14
|
+
|
|
1
15
|
## [1.4.20](https://github.com/adobe/helix-docx2md/compare/v1.4.19...v1.4.20) (2023-10-10)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-docx2md",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Helix library that converts word documents to markdown",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@adobe/helix-shared-process-queue": "3.0.0",
|
|
38
38
|
"@adobe/mammoth": "1.5.1-bleeding.2",
|
|
39
39
|
"@adobe/mdast-util-gridtables": "3.0.2",
|
|
40
|
-
"@adobe/remark-gridtables": "2.0.
|
|
40
|
+
"@adobe/remark-gridtables": "2.0.2",
|
|
41
41
|
"dirname-filename-esm": "1.1.1",
|
|
42
42
|
"github-slugger": "2.0.0",
|
|
43
43
|
"mdast-util-to-markdown": "2.1.0",
|
|
@@ -45,26 +45,26 @@
|
|
|
45
45
|
"remark-gfm": "4.0.0",
|
|
46
46
|
"remark-parse": "11.0.0",
|
|
47
47
|
"remark-stringify": "11.0.0",
|
|
48
|
-
"unified": "11.0.
|
|
48
|
+
"unified": "11.0.4",
|
|
49
49
|
"unist-util-find": "3.0.0",
|
|
50
50
|
"unist-util-visit": "5.0.0",
|
|
51
51
|
"yauzl": "2.10.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@adobe/eslint-config-helix": "2.0.
|
|
55
|
-
"@adobe/helix-admin-support": "2.2.
|
|
56
|
-
"@adobe/helix-mediahandler": "2.
|
|
57
|
-
"@adobe/helix-onedrive-support": "
|
|
58
|
-
"@adobe/helix-shared-tokencache": "1.3.
|
|
54
|
+
"@adobe/eslint-config-helix": "2.0.4",
|
|
55
|
+
"@adobe/helix-admin-support": "2.2.20",
|
|
56
|
+
"@adobe/helix-mediahandler": "2.3.0",
|
|
57
|
+
"@adobe/helix-onedrive-support": "11.1.0",
|
|
58
|
+
"@adobe/helix-shared-tokencache": "1.3.14",
|
|
59
59
|
"@semantic-release/changelog": "6.0.3",
|
|
60
60
|
"@semantic-release/exec": "6.0.3",
|
|
61
61
|
"@semantic-release/git": "10.0.1",
|
|
62
62
|
"c8": "8.0.1",
|
|
63
63
|
"dotenv": "16.3.1",
|
|
64
|
-
"eslint": "8.
|
|
64
|
+
"eslint": "8.52.0",
|
|
65
65
|
"husky": "8.0.3",
|
|
66
|
-
"junit-report-builder": "3.0
|
|
67
|
-
"lint-staged": "
|
|
66
|
+
"junit-report-builder": "3.1.0",
|
|
67
|
+
"lint-staged": "15.0.2",
|
|
68
68
|
"mocha": "10.2.0",
|
|
69
69
|
"mocha-multi-reporters": "1.5.1",
|
|
70
70
|
"semantic-release": "22.0.5",
|
|
@@ -39,6 +39,11 @@ const HEADING_MAP = {
|
|
|
39
39
|
'heading 8': 8,
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
function isHorizontalLine(nodes) {
|
|
43
|
+
const value = toString(nodes).trim();
|
|
44
|
+
return (value === '---' || value === '\u2014');
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
function getHeadingDepth(node) {
|
|
43
48
|
const { styleId, styleName } = node;
|
|
44
49
|
if (styleId in HEADING_MAP) {
|
|
@@ -265,8 +270,8 @@ export default function paragraph(h, node, parent, siblings) {
|
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
if (depth) {
|
|
268
|
-
// check if no
|
|
269
|
-
if (
|
|
273
|
+
// check if no horizontal line in heading
|
|
274
|
+
if (isHorizontalLine(nodes)) {
|
|
270
275
|
return h('thematicBreak');
|
|
271
276
|
}
|
|
272
277
|
const heading = h('heading', { depth }, nodes);
|
|
@@ -310,10 +315,10 @@ export default function paragraph(h, node, parent, siblings) {
|
|
|
310
315
|
// check for thematicBreaks and frontmatter. they need to be block elements
|
|
311
316
|
const ret = [];
|
|
312
317
|
let prevBreak;
|
|
313
|
-
let idx = nodes.findIndex(
|
|
318
|
+
let idx = nodes.findIndex(isHorizontalLine);
|
|
314
319
|
while (idx >= 0) {
|
|
315
320
|
const brk = h('thematicBreak');
|
|
316
|
-
// remove the nodes up until the
|
|
321
|
+
// remove the nodes up until the horizontal line
|
|
317
322
|
const removed = nodes.splice(0, idx);
|
|
318
323
|
// if last element is a break, ignore it.
|
|
319
324
|
if (removed.length && removed[removed.length - 1].type === 'break') {
|
|
@@ -321,7 +326,7 @@ export default function paragraph(h, node, parent, siblings) {
|
|
|
321
326
|
removed.pop();
|
|
322
327
|
}
|
|
323
328
|
|
|
324
|
-
// remove
|
|
329
|
+
// remove the horizontal line
|
|
325
330
|
nodes.splice(0, 1);
|
|
326
331
|
|
|
327
332
|
// also check if element following is a break
|
|
@@ -346,7 +351,7 @@ export default function paragraph(h, node, parent, siblings) {
|
|
|
346
351
|
ret.push(brk);
|
|
347
352
|
prevBreak = brk;
|
|
348
353
|
}
|
|
349
|
-
idx = nodes.findIndex(
|
|
354
|
+
idx = nodes.findIndex(isHorizontalLine);
|
|
350
355
|
}
|
|
351
356
|
|
|
352
357
|
// handle remaining nodes
|