@adobe/helix-docx2md 1.4.12 → 1.4.14

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.14](https://github.com/adobe/helix-docx2md/compare/v1.4.13...v1.4.14) (2023-08-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external major (major) ([#257](https://github.com/adobe/helix-docx2md/issues/257)) ([5d0eab8](https://github.com/adobe/helix-docx2md/commit/5d0eab84af84e0b3f605cd96df304386761456fe))
7
+
8
+ ## [1.4.13](https://github.com/adobe/helix-docx2md/compare/v1.4.12...v1.4.13) (2023-08-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * type error in inline code ([#274](https://github.com/adobe/helix-docx2md/issues/274)) ([ddb3960](https://github.com/adobe/helix-docx2md/commit/ddb3960c73300e4c4c00462edf8c111fb053a505))
14
+
1
15
  ## [1.4.12](https://github.com/adobe/helix-docx2md/compare/v1.4.11...v1.4.12) (2023-07-28)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-docx2md",
3
- "version": "1.4.12",
3
+ "version": "1.4.14",
4
4
  "description": "Helix library that converts word documents to markdown",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -40,32 +40,35 @@
40
40
  "@adobe/remark-gridtables": "1.0.4",
41
41
  "dirname-filename-esm": "1.1.1",
42
42
  "github-slugger": "2.0.0",
43
- "mdast-util-to-markdown": "1.5.0",
44
- "mdast-util-to-string": "3.2.0",
43
+ "mdast-util-to-markdown": "2.1.0",
44
+ "mdast-util-to-string": "4.0.0",
45
45
  "remark-gfm": "3.0.1",
46
46
  "remark-parse": "10.0.2",
47
47
  "remark-stringify": "10.0.3",
48
48
  "unified": "10.1.2",
49
- "unist-util-find": "1.0.4",
50
- "unist-util-visit": "4.1.2",
49
+ "unist-util-find": "3.0.0",
50
+ "unist-util-visit": "5.0.0",
51
51
  "yauzl": "2.10.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@adobe/eslint-config-helix": "2.0.2",
55
- "@adobe/helix-mediahandler": "2.2.6",
55
+ "@adobe/helix-admin-support": "2.2.3",
56
+ "@adobe/helix-mediahandler": "2.2.9",
57
+ "@adobe/helix-onedrive-support": "10.3.5",
58
+ "@adobe/helix-shared-tokencache": "1.3.4",
56
59
  "@semantic-release/changelog": "6.0.3",
57
60
  "@semantic-release/exec": "6.0.3",
58
61
  "@semantic-release/git": "10.0.1",
59
- "c8": "8.0.0",
62
+ "c8": "8.0.1",
60
63
  "dotenv": "16.3.1",
61
- "eslint": "8.45.0",
64
+ "eslint": "8.47.0",
62
65
  "husky": "8.0.3",
63
66
  "junit-report-builder": "3.0.1",
64
- "lint-staged": "13.2.3",
67
+ "lint-staged": "14.0.0",
65
68
  "mocha": "10.2.0",
66
69
  "mocha-multi-reporters": "1.5.1",
67
70
  "semantic-release": "21.0.7",
68
- "unist-util-inspect": "7.0.2"
71
+ "unist-util-inspect": "8.0.0"
69
72
  },
70
73
  "lint-staged": {
71
74
  "*.js": "eslint"
@@ -111,7 +111,7 @@ function collapseInlineCode(ret, prev) {
111
111
  if (next > 0) {
112
112
  // move first chunk to new paragraph
113
113
  const kids = children.splice(0, next);
114
- while (kids[kids.length - 1].type === 'break') {
114
+ while (kids[kids.length - 1]?.type === 'break') {
115
115
  kids.pop();
116
116
  }
117
117
  ret.splice(p, 0, {
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  import { visit } from 'unist-util-visit';
13
- import find from 'unist-util-find';
13
+ import { find } from 'unist-util-find';
14
14
 
15
15
  /**
16
16
  * Sanitizes auto embeds produced by word when entering a video link. The generated content consists
@@ -9,7 +9,15 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- import toMarkdown from './to-markdown.js';
12
+ import { listItem } from './list-item.js';
13
+
14
+ function toMarkdown() {
15
+ return {
16
+ handlers: {
17
+ listItem,
18
+ },
19
+ };
20
+ }
13
21
 
14
22
  export default function orderedListPlugin(options) {
15
23
  const data = this.data();
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Copyright 2021 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /**
13
+ * @param {State} state
14
+ * @returns {Exclude<Options['listItemIndent'], null | undefined>}
15
+ */
16
+ export function checkListItemIndent(state) {
17
+ const style = state.options.listItemIndent || 'one';
18
+
19
+ if (style !== 'tab' && style !== 'one' && style !== 'mixed') {
20
+ throw new Error(
21
+ `Cannot serialize items with \`${
22
+ style
23
+ }\` for \`options.listItemIndent\`, expected \`tab\`, \`one\`, or \`mixed\``,
24
+ );
25
+ }
26
+
27
+ return style;
28
+ }
29
+
30
+ /**
31
+ * @param {State} state
32
+ * @returns {Exclude<Options['bullet'], null | undefined>}
33
+ */
34
+ export function checkBullet(state) {
35
+ const marker = state.options.bullet || '*';
36
+
37
+ if (marker !== '*' && marker !== '+' && marker !== '-') {
38
+ throw new Error(
39
+ `Cannot serialize items with \`${
40
+ marker
41
+ }\` for \`options.bullet\`, expected \`*\`, \`+\`, or \`-\``,
42
+ );
43
+ }
44
+
45
+ return marker;
46
+ }
47
+
48
+ /**
49
+ * Renders a list item with 'number' support.
50
+ * copy of: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/list-item.js
51
+ *
52
+ * @param {ListItem} node
53
+ * @param {Parents | undefined} parent
54
+ * @param {State} state
55
+ * @param {Info} info
56
+ * @returns {string}
57
+ */
58
+ export function listItem(node, parent, state, info) {
59
+ const listItemIndent = checkListItemIndent(state);
60
+ let bullet = state.bulletCurrent || checkBullet(state);
61
+
62
+ // Add the marker value for ordered lists.
63
+ if (parent && parent.type === 'list' && parent.ordered) {
64
+ if (node.bullet !== undefined) {
65
+ bullet = node.bullet;
66
+ } else {
67
+ bullet = (typeof parent.start === 'number' && parent.start > -1
68
+ ? parent.start
69
+ : 1)
70
+ + (state.options.incrementListMarker === false
71
+ ? 0
72
+ : parent.children.indexOf(node))
73
+ + bullet;
74
+ }
75
+ }
76
+
77
+ let size = bullet.length + 1;
78
+
79
+ if (
80
+ listItemIndent === 'tab'
81
+ || (listItemIndent === 'mixed'
82
+ && ((parent && parent.type === 'list' && parent.spread) || node.spread))
83
+ ) {
84
+ size = Math.ceil(size / 4) * 4;
85
+ }
86
+
87
+ /** @type {Map} */
88
+ function map(line, index, blank) {
89
+ if (index) {
90
+ return (blank ? '' : ' '.repeat(size)) + line;
91
+ }
92
+ return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line;
93
+ }
94
+
95
+ const tracker = state.createTracker(info);
96
+ tracker.move(bullet + ' '.repeat(size - bullet.length));
97
+ tracker.shift(size);
98
+ const exit = state.enter('listItem');
99
+ const value = state.indentLines(
100
+ state.containerFlow(node, tracker.current()),
101
+ map,
102
+ );
103
+ exit();
104
+
105
+ return value;
106
+ }
@@ -1,67 +0,0 @@
1
- /*
2
- * Copyright 2021 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
- import { checkBullet } from 'mdast-util-to-markdown/lib/util/check-bullet.js';
13
- import { checkListItemIndent } from 'mdast-util-to-markdown/lib/util/check-list-item-indent.js';
14
- import { containerFlow as flow } from 'mdast-util-to-markdown/lib/util/container-flow.js';
15
- import { indentLines } from 'mdast-util-to-markdown/lib/util/indent-lines.js';
16
-
17
- /**
18
- * Renders a list item with 'number' support.
19
- * copy of: https://github.com/syntax-tree/mdast-util-to-markdown/blob/main/lib/handle/list-item.js
20
- */
21
- function listItem(node, parent, context) {
22
- let bullet = checkBullet(context);
23
- const listItemIndent = checkListItemIndent(context);
24
- let size;
25
-
26
- if (parent && parent.ordered) {
27
- if (node.bullet !== undefined) {
28
- bullet = node.bullet;
29
- } else {
30
- bullet = `${(parent.start > -1 ? parent.start : 1)
31
- + (context.options.incrementListMarker === false
32
- ? 0
33
- : parent.children.indexOf(node))
34
- }.`;
35
- }
36
- }
37
-
38
- size = bullet.length + 1;
39
-
40
- if (
41
- listItemIndent === 'tab'
42
- || (listItemIndent === 'mixed' && ((parent && parent.spread) || node.spread))
43
- ) {
44
- size = Math.ceil(size / 4) * 4;
45
- }
46
-
47
- function map(line, index, blank) {
48
- if (index) {
49
- return (blank ? '' : ' '.repeat(size)) + line;
50
- }
51
- return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line;
52
- }
53
-
54
- const exit = context.enter('listItem');
55
- const value = indentLines(flow(node, context), map);
56
- exit();
57
-
58
- return value;
59
- }
60
-
61
- export default function toMarkdown() {
62
- return {
63
- handlers: {
64
- listItem,
65
- },
66
- };
67
- }