@adobe/helix-importer 2.8.13 → 2.9.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
+ # [2.9.0](https://github.com/adobe/helix-importer/compare/v2.8.13...v2.9.0) (2023-04-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * implement superscript and subscript support ([#137](https://github.com/adobe/helix-importer/issues/137)) ([1f0d97f](https://github.com/adobe/helix-importer/commit/1f0d97fd844d7f8d2145970b97348211efd026e2))
7
+
1
8
  ## [2.8.13](https://github.com/adobe/helix-importer/compare/v2.8.12...v2.8.13) (2023-04-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-importer",
3
- "version": "2.8.13",
3
+ "version": "2.9.0",
4
4
  "description": "Helix Importer tool: create md / docx from html",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -33,6 +33,21 @@ function remarkImageReferences() {
33
33
  return imageReferences;
34
34
  }
35
35
 
36
+ function htmlElementNode(element, state, node) {
37
+ if (node.children && node.children.length > 0) {
38
+ return [{
39
+ type: 'html',
40
+ value: `<${element}>`,
41
+ },
42
+ ...state.all(node),
43
+ {
44
+ type: 'html',
45
+ value: `</${element}>`,
46
+ }];
47
+ }
48
+ return '';
49
+ }
50
+
36
51
  export default class PageImporter {
37
52
  params;
38
53
 
@@ -65,20 +80,9 @@ export default class PageImporter {
65
80
  .use(parse, { emitParseErrors: true })
66
81
  .use(rehype2remark, {
67
82
  handlers: {
68
- u: (state, node) => {
69
- if (node.children && node.children.length > 0) {
70
- return [{
71
- type: 'html',
72
- value: '<u>',
73
- },
74
- ...state.all(node),
75
- {
76
- type: 'html',
77
- value: '</u>',
78
- }];
79
- }
80
- return '';
81
- },
83
+ u: (state, node) => htmlElementNode('u', state, node),
84
+ sub: (state, node) => htmlElementNode('sub', state, node),
85
+ sup: (state, node) => htmlElementNode('sup', state, node),
82
86
  ...gridtableHandlers,
83
87
  },
84
88
  })
@@ -178,7 +178,7 @@ describe('PageImporter tests - fixtures', () => {
178
178
  await featureTest('space');
179
179
  });
180
180
 
181
- it('import - strikethroughs', async () => {
182
- await featureTest('s');
181
+ it('import - sub and sup', async () => {
182
+ await featureTest('subsup');
183
183
  });
184
184
  });
@@ -0,0 +1,7 @@
1
+ <html>
2
+ <body>
3
+ <h1>sub and sup</h1>
4
+ <p>This text must be a <sub>subscript</sub>.</p>
5
+ <p>This text must be a <sup>superscript</sup>.</p>
6
+ </body>
7
+ </html>
@@ -0,0 +1,5 @@
1
+ # sub and sup
2
+
3
+ This text must be a <sub>subscript</sub>.
4
+
5
+ This text must be a <sup>superscript</sup>.