@adobe/helix-docx2md 1.4.16 → 1.4.18

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,17 @@
1
+ ## [1.4.18](https://github.com/adobe/helix-docx2md/compare/v1.4.17...v1.4.18) (2023-09-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix problems with duplicate bookmarks ([#312](https://github.com/adobe/helix-docx2md/issues/312)) ([37366a0](https://github.com/adobe/helix-docx2md/commit/37366a00643803f715d0721129b4e28ada2b4a45))
7
+
8
+ ## [1.4.17](https://github.com/adobe/helix-docx2md/compare/v1.4.16...v1.4.17) (2023-09-26)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * imports ([#308](https://github.com/adobe/helix-docx2md/issues/308)) ([1087b0c](https://github.com/adobe/helix-docx2md/commit/1087b0cd1dc4896f2f9e6e0a52da41d551841ee7))
14
+
1
15
  ## [1.4.16](https://github.com/adobe/helix-docx2md/compare/v1.4.15...v1.4.16) (2023-09-26)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-docx2md",
3
- "version": "1.4.16",
3
+ "version": "1.4.18",
4
4
  "description": "Helix library that converts word documents to markdown",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -54,8 +54,8 @@
54
54
  "@adobe/eslint-config-helix": "2.0.3",
55
55
  "@adobe/helix-admin-support": "2.2.12",
56
56
  "@adobe/helix-mediahandler": "2.2.16",
57
- "@adobe/helix-onedrive-support": "10.8.0",
58
- "@adobe/helix-shared-tokencache": "1.3.8",
57
+ "@adobe/helix-onedrive-support": "10.8.3",
58
+ "@adobe/helix-shared-tokencache": "1.3.9",
59
59
  "@semantic-release/changelog": "6.0.3",
60
60
  "@semantic-release/exec": "6.0.3",
61
61
  "@semantic-release/git": "10.0.1",
@@ -111,9 +111,11 @@ export default async function dast2mdast(tree, opts = {}) {
111
111
  bm.id = '';
112
112
  } else if (bm.target.type === 'heading') {
113
113
  // if heading, create an ID from its text
114
- const text = toString(bm.target).trim();
115
- bm.id = slugger.slug(text || 'heading');
116
- bm.target.id = bm.id;
114
+ if (!bm.target.id) {
115
+ const text = toString(bm.target).trim();
116
+ bm.target.id = slugger.slug(text || 'heading');
117
+ }
118
+ bm.id = bm.target.id;
117
119
  } else if (bm.links.length) {
118
120
  // create an anchor node for non-heading bookmarks
119
121
  bm.id = slugger.slug('bookmark');
@@ -18,7 +18,13 @@
18
18
  */
19
19
  export default function bookmark(h, node) {
20
20
  const bm = h.getBookmark(node.name);
21
+ if (bm.target) {
22
+ // eslint-disable-next-line no-console
23
+ console.warn(`bookmark ${node.name} is already defined`);
24
+ return null;
25
+ }
21
26
  bm.target = h('bookmark', node.name);
22
- bm.target.bookmark = bm;
27
+ // do not enumerate, so that it doesn't trip inspect
28
+ Object.defineProperty(bm.target, 'bookmark', { enumerable: false, value: bm });
23
29
  return bm.target;
24
30
  }
@@ -270,12 +270,15 @@ export default function paragraph(h, node, parent, siblings) {
270
270
  return h('thematicBreak');
271
271
  }
272
272
  const heading = h('heading', { depth }, nodes);
273
- // check if any of the children is a bookmark
274
- const idx = nodes.findIndex((n) => n.type === 'bookmark');
275
- if (idx >= 0) {
276
- // replace the bookmark node with this heading and remove the child
277
- nodes[idx].bookmark.target = heading;
278
- nodes.splice(idx, 1);
273
+ // check bookmark children (could have multiple)
274
+ for (let idx = 0; idx < nodes.length; idx += 1) {
275
+ const child = nodes[idx];
276
+ if (child.type === 'bookmark') {
277
+ // set the bookmark target to this heading and remove the child
278
+ child.bookmark.target = heading;
279
+ nodes.splice(idx, 1);
280
+ idx -= 1;
281
+ }
279
282
  }
280
283
  return heading;
281
284
  }
@@ -15,8 +15,7 @@ import stringify from 'remark-stringify';
15
15
  import { unified } from 'unified';
16
16
  import gfm from 'remark-gfm';
17
17
 
18
- // eslint-disable-next-line no-unused-vars,import/no-extraneous-dependencies
19
- import { inspect } from 'unist-util-inspect';
18
+ // import { inspect } from 'unist-util-inspect';
20
19
  import {
21
20
  robustTables,
22
21
  suppressSpaceCode,