@adobe/helix-md2docx 2.1.98 → 2.1.100

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
+ ## [2.1.100](https://github.com/adobe/helix-md2docx/compare/v2.1.99...v2.1.100) (2025-02-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency hast-util-to-mdast to v10.1.2 ([#543](https://github.com/adobe/helix-md2docx/issues/543)) ([f5d9f8b](https://github.com/adobe/helix-md2docx/commit/f5d9f8bc2e9ae40479eb053a9c12fd63df4789bc))
7
+
8
+ ## [2.1.99](https://github.com/adobe/helix-md2docx/compare/v2.1.98...v2.1.99) (2025-01-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * properly handle subscript in links ([#542](https://github.com/adobe/helix-md2docx/issues/542)) ([b43912d](https://github.com/adobe/helix-md2docx/commit/b43912d3f9a634443ad5058ef9e2a8efbf4437ee)), closes [#537](https://github.com/adobe/helix-md2docx/issues/537)
14
+
1
15
  ## [2.1.98](https://github.com/adobe/helix-md2docx/compare/v2.1.97...v2.1.98) (2025-01-26)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2docx",
3
- "version": "2.1.98",
3
+ "version": "2.1.100",
4
4
  "description": "Helix Service that converts markdown to word documents",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "docx": "9.1.1",
37
37
  "github-slugger": "2.0.0",
38
38
  "hast-util-is-element": "3.0.0",
39
- "hast-util-to-mdast": "10.1.1",
39
+ "hast-util-to-mdast": "10.1.2",
40
40
  "image-size": "1.2.0",
41
41
  "mdast-util-to-string": "4.0.0",
42
42
  "mime": "4.0.6",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@adobe/eslint-config-helix": "2.0.8",
51
- "@adobe/helix-mediahandler": "2.5.47",
51
+ "@adobe/helix-mediahandler": "2.5.48",
52
52
  "@semantic-release/changelog": "6.0.3",
53
53
  "@semantic-release/exec": "6.0.3",
54
54
  "@semantic-release/git": "10.0.1",
@@ -60,8 +60,8 @@
60
60
  "eslint-plugin-import": "2.31.0",
61
61
  "husky": "9.1.7",
62
62
  "junit-report-builder": "5.1.1",
63
- "lint-staged": "15.4.1",
64
- "mocha": "11.0.1",
63
+ "lint-staged": "15.4.3",
64
+ "mocha": "11.1.0",
65
65
  "mocha-multi-reporters": "1.5.1",
66
66
  "nock": "13.5.6",
67
67
  "semantic-release": "24.2.1",
@@ -104,6 +104,21 @@ function isPhrasingParent(node) {
104
104
  ].includes(node.type);
105
105
  }
106
106
 
107
+ const FORMATS = {
108
+ '<sub>': {
109
+ closing: '</sub>',
110
+ type: 'subscript',
111
+ },
112
+ '<sup>': {
113
+ closing: '</sup>',
114
+ type: 'superscript',
115
+ },
116
+ '<u>': {
117
+ closing: '</u>',
118
+ type: 'underline',
119
+ },
120
+ };
121
+
107
122
  /**
108
123
  * Sanitizes html:
109
124
  * - collapses consecutive html content (simply concat all nodes until the last html sibling)
@@ -127,6 +142,27 @@ export default function sanitizeHtml(tree) {
127
142
  delete node.value;
128
143
  return visit.CONTINUE;
129
144
  }
145
+
146
+ // try to convert simple formats
147
+ const simple = FORMATS[node.value];
148
+ if (simple) {
149
+ let i = index + 1;
150
+ while (i < siblings.length && siblings[i].type !== 'html' && siblings[i].value !== simple.closing) {
151
+ i += 1;
152
+ }
153
+ if (i < siblings.length && siblings[i].value === simple.closing) {
154
+ const removed = siblings.splice(index + 1, i - index);
155
+ removed.pop();
156
+ // eslint-disable-next-line no-param-reassign
157
+ node.type = simple.type;
158
+ // eslint-disable-next-line no-param-reassign
159
+ node.children = removed;
160
+ // eslint-disable-next-line no-param-reassign
161
+ delete node.value;
162
+ return index + 1;
163
+ }
164
+ }
165
+
130
166
  // find last html block
131
167
  let lastHtml = siblings.length - 1;
132
168
  while (lastHtml >= index) {