@adobe/helix-importer 1.2.2 → 1.4.1
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 +21 -0
- package/package.json +3 -2
- package/src/importer/PageImporter.js +18 -55
- package/src/importer/PageImporterParams.js +2 -0
- package/src/utils/Blocks.js +3 -7
- package/src/utils/MDUtils.js +21 -0
- package/test/explorers/PagingExplorer.spec.js +75 -0
- package/test/importers/PageImporter.spec.js +87 -0
- package/test/importers/fixtures/complex.spec.html +70 -0
- package/test/importers/fixtures/complex.spec.md +54 -0
- package/test/importers/fixtures/custom-styles.xml +1084 -0
- package/test/importers/fixtures/em.spec.html +8 -0
- package/test/importers/fixtures/em.spec.md +7 -0
- package/test/importers/fixtures/link.spec.html +9 -0
- package/test/importers/fixtures/link.spec.md +9 -0
- package/test/importers/fixtures/span.spec.html +6 -0
- package/test/importers/fixtures/span.spec.md +3 -0
- package/test/importers/fixtures/table.spec.html +31 -0
- package/test/importers/fixtures/table.spec.md +5 -0
- package/test/importers/fixtures/u.spec.html +17 -0
- package/test/importers/fixtures/u.spec.md +19 -0
- package/test/utils/Blocks.spec.js +6 -2
- package/test/utils/MDUtils.spec.js +54 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<h1>EM sample</h1>
|
|
4
|
+
<p><strong><em> </em></strong></p><p>usefull</p>
|
|
5
|
+
<p><strong><em>emphasis</em></strong><strong><em> space </em></strong><strong><em>another emphasis</em></strong> <strong><em>last emphasis</em></strong></p>
|
|
6
|
+
<p><a href="https://www.sample.com">linkcontent</a><i>. </i></p>
|
|
7
|
+
</body>
|
|
8
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<h1>Links sample</h1>
|
|
4
|
+
<p><a href="http://wwww.sample.com/a">Link on a single online</a></p>
|
|
5
|
+
<a href="http://wwww.sample.com/b">Link without p</a>
|
|
6
|
+
<p>http://wwww.sample.com/c</p>
|
|
7
|
+
<hlxembed>http://wwww.sample.com/d</hlxembed>
|
|
8
|
+
</body>
|
|
9
|
+
</html>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<h1>Spans sample</h1>
|
|
4
|
+
<p><span>spans </span> can be a mess, <span>especially</span><span> </span>when<span> </span>used for<span> </span><span>spaces</span>, or <span><b>mixed</b> with other tags</span>. <a href="http://wwww.sample.com/">Link with a <span>span</span>.</a></p>
|
|
5
|
+
</body>
|
|
6
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<h1>Table sample</h1>
|
|
4
|
+
<table>
|
|
5
|
+
<tr><td colspan="2">Metadata</td></tr>
|
|
6
|
+
<tr><td>Title</td><td>This is the title of the page</td></tr>
|
|
7
|
+
<tr><td>Link</td><td><a href="https://www.sample.com"> A link</a></td></tr>
|
|
8
|
+
<tr>
|
|
9
|
+
<td>List</td>
|
|
10
|
+
<td><ul>
|
|
11
|
+
<li>Value 1</li>
|
|
12
|
+
<li>Value 2</li>
|
|
13
|
+
<li>Another value...</li>
|
|
14
|
+
</ul></td>
|
|
15
|
+
</tr>
|
|
16
|
+
<tr><td>Paragraphs</td><td><p>Paragraph 1 with some text</p><p>Paragraph 2 with some text too!</p></td></tr>
|
|
17
|
+
</table>
|
|
18
|
+
<table>
|
|
19
|
+
<tr><th colspan="2">Metadata</th></tr>
|
|
20
|
+
<tr><td>title</td><td>Some title</td></tr>
|
|
21
|
+
<tr>
|
|
22
|
+
<td>Tags</td>
|
|
23
|
+
<td>
|
|
24
|
+
<p>Creative</p>
|
|
25
|
+
<p>Experience Cloud</p>
|
|
26
|
+
<p>Photography</p>
|
|
27
|
+
</td>
|
|
28
|
+
</tr>
|
|
29
|
+
</table>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Table sample
|
|
2
|
+
|
|
3
|
+
<table><tbody><tr><td colspan="2">Metadata</td></tr><tr><td>Title</td><td>This is the title of the page</td></tr><tr><td>Link</td><td><span></span><a href="https://www.sample.com">A link</a></td></tr><tr><td>List</td><td><ul><li>Value 1</li><li>Value 2</li><li>Another value...</li></ul></td></tr><tr><td>Paragraphs</td><td><p>Paragraph 1 with some text</p><p>Paragraph 2 with some text too!</p></td></tr></tbody></table>
|
|
4
|
+
|
|
5
|
+
<table><tbody><tr><th colspan="2">Metadata</th></tr><tr><td>title</td><td>Some title</td></tr><tr><td>Tags</td><td><p>Creative</p><p>Experience Cloud</p><p>Photography</p></td></tr></tbody></table>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<h1>Underline combo sample</h1>
|
|
4
|
+
<p><u>Underline 1</u></p>
|
|
5
|
+
<p>Some normal text with random <u>underline</u> or <span><u>span with underline</u></span> or <u><span>underline with span</u>...</p>
|
|
6
|
+
<p><span><strong><u>Underline 2</u></strong></span></p>
|
|
7
|
+
<p><strong><u>Underline 3</u></strong></p>
|
|
8
|
+
<ul>
|
|
9
|
+
<li><u>li underline 1</u></li>
|
|
10
|
+
<li><u>li underline 2</u> also may have text here</li>
|
|
11
|
+
<li><u>li underline 3</u></li>
|
|
12
|
+
</ul>
|
|
13
|
+
<p>
|
|
14
|
+
<u><a href="https:/www.sample.com/a">Unlined link</a></u> or <a href="https:/www.sample.com/b"><u>Linked underline</u></a> ?
|
|
15
|
+
</p>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Underline combo sample
|
|
2
|
+
|
|
3
|
+
<u>Underline 1</u>
|
|
4
|
+
|
|
5
|
+
Some normal text with random <u>underline</u> or <u>span with underline</u> or <u>underline with span</u>...
|
|
6
|
+
|
|
7
|
+
**<u>Underline 2</u>**
|
|
8
|
+
|
|
9
|
+
**<u>Underline 3</u>**
|
|
10
|
+
|
|
11
|
+
- <u>li underline 1</u>
|
|
12
|
+
|
|
13
|
+
- <u>li underline 2</u>
|
|
14
|
+
|
|
15
|
+
also may have text here
|
|
16
|
+
|
|
17
|
+
- <u>li underline 3</u>
|
|
18
|
+
|
|
19
|
+
[Unlined link](https:/www.sample.com/a) or [<u>Linked underline</u>](https:/www.sample.com/b) ?
|
|
@@ -96,6 +96,7 @@ describe('Blocks#convertBlocksToTables tests', () => {
|
|
|
96
96
|
<div class="promotion">
|
|
97
97
|
<div>
|
|
98
98
|
<div><a href="https://blog.adobe.com/en/promotions/doc-cloud-education.html">https://blog.adobe.com/en/promotions/doc-cloud-education.html</a></div>
|
|
99
|
+
<div><span>with content</span></div>
|
|
99
100
|
</div>
|
|
100
101
|
</div>
|
|
101
102
|
</main>`,
|
|
@@ -103,7 +104,10 @@ describe('Blocks#convertBlocksToTables tests', () => {
|
|
|
103
104
|
<div>
|
|
104
105
|
<table>
|
|
105
106
|
<tr><th>Promotion</th></tr>
|
|
106
|
-
<tr
|
|
107
|
+
<tr>
|
|
108
|
+
<td><a href="https://blog.adobe.com/en/promotions/doc-cloud-education.html">https://blog.adobe.com/en/promotions/doc-cloud-education.html</a></td>
|
|
109
|
+
<td><span>with content</span></td>
|
|
110
|
+
</tr>
|
|
107
111
|
</table>
|
|
108
112
|
</div>
|
|
109
113
|
</main>`,
|
|
@@ -133,6 +137,6 @@ describe('Blocks#getMetadataBlock tests', () => {
|
|
|
133
137
|
});
|
|
134
138
|
|
|
135
139
|
it('getMetadataBlock lists', () => {
|
|
136
|
-
test({ title: 'Some title', Tags: ['Creative', 'Experience Cloud', 'Photography'] }, '<table><tr><th colspan="2">Metadata</th></tr><tr><td>title</td><td>Some title</td></tr><tr><td>Tags</td><td>
|
|
140
|
+
test({ title: 'Some title', Tags: ['Creative', 'Experience Cloud', 'Photography'] }, '<table><tr><th colspan="2">Metadata</th></tr><tr><td>title</td><td>Some title</td></tr><tr><td>Tags</td><td><p>Creative</p><p>Experience Cloud</p><p>Photography</p></td></tr></table>');
|
|
137
141
|
});
|
|
138
142
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 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
|
+
import { strictEqual } from 'assert';
|
|
14
|
+
import { describe, it } from 'mocha';
|
|
15
|
+
|
|
16
|
+
import MDUtils from '../../src/utils/MDUtils.js';
|
|
17
|
+
|
|
18
|
+
describe('MDUtils tests', () => {
|
|
19
|
+
it('MDUtils#replaceSrcInMarkdown do nothing', () => {
|
|
20
|
+
strictEqual(
|
|
21
|
+
MDUtils.replaceSrcInMarkdown('#A title\n', 'https://www.sample.com/replace.jpg', 'https://www.sample.com/withimage.jpg'),
|
|
22
|
+
'#A title\n',
|
|
23
|
+
'do nothing',
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('MDUtils#replaceSrcInMarkdown can replace', () => {
|
|
28
|
+
strictEqual(
|
|
29
|
+
MDUtils.replaceSrcInMarkdown('#A title\n', 'https://www.sample.com/image.jpg', 'https://www.sample.com/withimage.jpg'),
|
|
30
|
+
'#A title\n',
|
|
31
|
+
'basic replacement',
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
strictEqual(
|
|
35
|
+
MDUtils.replaceSrcInMarkdown('#A title\n', '/image.jpg', 'https://www.sample.com/image.jpg'),
|
|
36
|
+
'#A title\n',
|
|
37
|
+
'relative to absolute replacement',
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
strictEqual(
|
|
41
|
+
MDUtils.replaceSrcInMarkdown('\n\n# Title for the page', '/book/resources/_prod/img/hero/image.jpg', 'https://www.sample.com/book/resources/_prod/img/hero/image.jpg'),
|
|
42
|
+
'\n\n# Title for the page',
|
|
43
|
+
'relative to absolute replacement (no double replacement)',
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('MDUtils#replaceSrcInMarkdown can replace with encoding', () => {
|
|
48
|
+
strictEqual(
|
|
49
|
+
MDUtils.replaceSrcInMarkdown('#A title\n', 'https://www.sample.com/imag%C3%A9.jpg', 'https://www.sample.com/withsomethingelse.jpg'),
|
|
50
|
+
'#A title\n',
|
|
51
|
+
'encoded to replacement',
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|