@adobe/helix-docx2md 1.6.4 → 1.6.6

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.6.6](https://github.com/adobe/helix-docx2md/compare/v1.6.5...v1.6.6) (2024-08-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update adobe fixes ([256c66d](https://github.com/adobe/helix-docx2md/commit/256c66de1413d0ea7958d15ac27f9c2523e5067f))
7
+
8
+ ## [1.6.5](https://github.com/adobe/helix-docx2md/compare/v1.6.4...v1.6.5) (2024-08-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * 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)
14
+
1
15
  ## [1.6.4](https://github.com/adobe/helix-docx2md/compare/v1.6.3...v1.6.4) (2024-07-13)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-docx2md",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
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": "7.1.4",
37
+ "@adobe/helix-markdown-support": "7.1.5",
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",
@@ -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.22",
57
- "@adobe/helix-mediahandler": "2.5.13",
58
- "@adobe/helix-onedrive-support": "11.5.5",
59
- "@adobe/helix-shared-tokencache": "1.4.22",
56
+ "@adobe/helix-admin-support": "2.9.3",
57
+ "@adobe/helix-mediahandler": "2.5.19",
58
+ "@adobe/helix-onedrive-support": "11.5.13",
59
+ "@adobe/helix-shared-tokencache": "1.4.29",
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.0.11",
67
- "junit-report-builder": "3.2.1",
68
- "lint-staged": "15.2.7",
69
- "mocha": "10.6.0",
66
+ "husky": "9.1.5",
67
+ "junit-report-builder": "5.0.0",
68
+ "lint-staged": "15.2.9",
69
+ "mocha": "10.7.3",
70
70
  "mocha-multi-reporters": "1.5.1",
71
- "semantic-release": "24.0.0",
72
- "unist-util-inspect": "8.0.0"
71
+ "semantic-release": "24.1.0",
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 (value === '---' || value === '\u2014');
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
- // check if no horizontal line in heading
281
- if (isHorizontalLine(nodes)) {
282
- ret.push(h('thematicBreak'));
283
- } else {
284
- const heading = h('heading', { depth }, nodes);
285
- // check bookmark children (could have multiple)
286
- for (let idx = 0; idx < nodes.length; idx += 1) {
287
- const child = nodes[idx];
288
- if (child.type === 'bookmark') {
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