@adobe/helix-importer 1.6.0 → 1.7.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.7.0](https://github.com/adobe/helix-importer/compare/v1.6.0...v1.7.0) (2022-03-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * do not change span with an image ([db51e1c](https://github.com/adobe/helix-importer/commit/db51e1cb068d44571c97c83d6e25b38f8e27003e))
7
+
1
8
  # [1.6.0](https://github.com/adobe/helix-importer/compare/v1.5.0...v1.6.0) (2022-02-24)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-importer",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Helix Importer tool: create md / docx from html",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -144,10 +144,13 @@ export default class DOMUtils {
144
144
  static removeSpans(document) {
145
145
  // remove spans
146
146
  document.querySelectorAll('span').forEach((span) => {
147
- if (span.textContent === '') {
148
- span.remove();
149
- } else {
150
- span.replaceWith(JSDOM.fragment(span.innerHTML));
147
+ if (!span.querySelector('img')) {
148
+ // do not touch spans with images
149
+ if (span.textContent === '') {
150
+ span.remove();
151
+ } else {
152
+ span.replaceWith(JSDOM.fragment(span.innerHTML));
153
+ }
151
154
  }
152
155
  });
153
156
  }
@@ -188,6 +188,8 @@ describe('DOMUtils#removeSpans tests', () => {
188
188
  test('<p><span>Content should remain</span> the same</p>', '<p>Content should remain the same</p>');
189
189
  test('<p>Spacing<span> should</span> remain the same</p>', '<p>Spacing should remain the same</p>');
190
190
  test('<p>Spacing<span> should</span> remain the <span>same even</span> with<span> multiple spans</span></p>', '<p>Spacing should remain the same even with multiple spans</p>');
191
+ test('<span><div><img src="animage.jpg"></div></span>', '<span><div><img src="animage.jpg"></div></span>');
192
+ test('<span>Some image here: <div><img src="animage.jpg"></div></span>', '<span>Some image here: <div><img src="animage.jpg"></div></span>');
191
193
  });
192
194
  });
193
195