@diplodoc/cli-tests 5.28.0 → 5.30.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.
Files changed (32) hide show
  1. package/e2e/__snapshots__/bundles.spec.ts.snap +1 -1
  2. package/e2e/__snapshots__/files.test.ts.snap +1 -1
  3. package/e2e/__snapshots__/include-toc.test.ts.snap +207 -0
  4. package/e2e/__snapshots__/includes.test.ts.snap +4 -4
  5. package/e2e/__snapshots__/neuro-expert.test.ts.snap +2 -2
  6. package/e2e/__snapshots__/pdf-page.spec.ts.snap +11 -7
  7. package/e2e/__snapshots__/regression.test.ts.snap +8 -8
  8. package/e2e/__snapshots__/skip-html-extension.spec.ts.snap +3 -3
  9. package/e2e/disable-csp.spec.ts +55 -0
  10. package/e2e/include-toc.test.ts +12 -0
  11. package/mocks/disable-csp/input/.yfm +8 -0
  12. package/mocks/disable-csp/input/en/index.md +3 -0
  13. package/mocks/disable-csp/input/en/page.md +3 -0
  14. package/mocks/disable-csp/input/en/toc.yaml +5 -0
  15. package/mocks/include-toc/test8/input/test/index.md +4 -0
  16. package/mocks/include-toc/test8/input/test/sub/index.md +1 -0
  17. package/mocks/include-toc/test8/input/test/sub/sub/sub-3.md +1 -0
  18. package/mocks/include-toc/test8/input/test/sub/sub-1.md +5 -0
  19. package/mocks/include-toc/test8/input/test/sub/sub-2.md +1 -0
  20. package/mocks/include-toc/test8/input/test/test.md +1 -0
  21. package/mocks/include-toc/test8/input/toc.yaml +9 -0
  22. package/mocks/include-toc/test9/input/test/index.md +4 -0
  23. package/mocks/include-toc/test9/input/test/sub/index.md +1 -0
  24. package/mocks/include-toc/test9/input/test/sub/sub/sub-3.md +1 -0
  25. package/mocks/include-toc/test9/input/test/sub/sub-1.md +5 -0
  26. package/mocks/include-toc/test9/input/test/sub/sub-2.md +1 -0
  27. package/mocks/include-toc/test9/input/test/test.md +1 -0
  28. package/mocks/include-toc/test9/input/toc.yaml +8 -0
  29. package/mocks/pdf-page/title-pages/input/pdf-endings/pdf-ending-page1.md +13 -0
  30. package/mocks/pdf-page/title-pages/input/pdf-endings/pdf-ending-page2.md +3 -0
  31. package/mocks/pdf-page/title-pages/input/toc.yaml +3 -0
  32. package/package.json +1 -1
@@ -143,7 +143,7 @@ exports[`Skip html extension > correctly trims .html and index.html on monolingu
143
143
  <body class="g-root g-root_theme_light">
144
144
  <div id="root"></div>
145
145
  <script type="application/json" id="diplodoc-state">
146
- {"data":{"leading":false,"html":"&lt;h2 id=\\"hash\\"&gt;&lt;a href=\\"page2#hash\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;hash&lt;/span&gt;&lt;/a&gt;hash&lt;/h2&gt;/n&lt;p&gt;&lt;a href=\\"folder/\\"&gt;Link&lt;/a&gt;&lt;br /&gt;/n&lt;a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\"&gt;External link&lt;/a&gt;&lt;/p&gt;/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"page2.md"},"headings":[{"title":"hash","href":"page2#hash","level":2}],"title":"Page 2"},"router":{"pathname":"page2","depth":1,"base":"./"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
146
+ {"data":{"leading":false,"html":"&lt;h2 id=\\"hash\\"&gt;&lt;a href=\\"page2#hash\\" class=\\"yfm-anchor yfm-clipboard-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;hash&lt;/span&gt;&lt;/a&gt;hash&lt;/h2&gt;/n&lt;p&gt;&lt;a href=\\"folder/\\"&gt;Link&lt;/a&gt;&lt;br /&gt;/n&lt;a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\"&gt;External link&lt;/a&gt;&lt;/p&gt;/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"page2.md"},"headings":[{"title":"hash","href":"page2#hash","level":2}],"title":"Page 2"},"router":{"pathname":"page2","depth":1,"base":"./"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
147
147
  </script>
148
148
  <script type="application/javascript">
149
149
  const data = document.querySelector('script#diplodoc-state');
@@ -325,7 +325,7 @@ exports[`Skip html extension > correctly trims .html and index.html on multiling
325
325
  <body class="g-root g-root_theme_light">
326
326
  <div id="root"></div>
327
327
  <script type="application/json" id="diplodoc-state">
328
- {"data":{"leading":false,"html":"&lt;h2 id=\\"hash\\"&gt;&lt;a href=\\"en/page2#hash\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;hash&lt;/span&gt;&lt;/a&gt;hash&lt;/h2&gt;/n&lt;p&gt;&lt;a href=\\"en/folder/\\"&gt;Link&lt;/a&gt;&lt;br /&gt;/n&lt;a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\"&gt;External link&lt;/a&gt;&lt;/p&gt;/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"en/page2","vcsPath":"en/page2.md"},"headings":[{"title":"hash","href":"en/page2#hash","level":2}],"title":"Page 2"},"router":{"pathname":"en/page2","depth":2,"base":"../"},"lang":"en","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
328
+ {"data":{"leading":false,"html":"&lt;h2 id=\\"hash\\"&gt;&lt;a href=\\"en/page2#hash\\" class=\\"yfm-anchor yfm-clipboard-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;hash&lt;/span&gt;&lt;/a&gt;hash&lt;/h2&gt;/n&lt;p&gt;&lt;a href=\\"en/folder/\\"&gt;Link&lt;/a&gt;&lt;br /&gt;/n&lt;a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\"&gt;External link&lt;/a&gt;&lt;/p&gt;/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"en/page2","vcsPath":"en/page2.md"},"headings":[{"title":"hash","href":"en/page2#hash","level":2}],"title":"Page 2"},"router":{"pathname":"en/page2","depth":2,"base":"../"},"lang":"en","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
329
329
  </script>
330
330
  <script type="application/javascript">
331
331
  const data = document.querySelector('script#diplodoc-state');
@@ -502,7 +502,7 @@ exports[`Skip html extension > correctly trims .html and index.html on multiling
502
502
  <body class="g-root g-root_theme_light">
503
503
  <div id="root"></div>
504
504
  <script type="application/json" id="diplodoc-state">
505
- {"data":{"leading":false,"html":"&lt;h2 id=\\"hesh\\"&gt;&lt;a href=\\"ru/page2#hesh\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;хэш&lt;/span&gt;&lt;/a&gt;хэш&lt;/h2&gt;/n&lt;p&gt;&lt;a href=\\"ru/folder/\\"&gt;Ссылка&lt;/a&gt;&lt;br /&gt;/n&lt;a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\"&gt;Внешняя ссылка&lt;/a&gt;&lt;/p&gt;/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"ru/page2","vcsPath":"ru/page2.md"},"headings":[{"title":"хэш","href":"ru/page2#hesh","level":2}],"title":"Страница 2"},"router":{"pathname":"ru/page2","depth":2,"base":"../"},"lang":"ru","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
505
+ {"data":{"leading":false,"html":"&lt;h2 id=\\"hesh\\"&gt;&lt;a href=\\"ru/page2#hesh\\" class=\\"yfm-anchor yfm-clipboard-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;хэш&lt;/span&gt;&lt;/a&gt;хэш&lt;/h2&gt;/n&lt;p&gt;&lt;a href=\\"ru/folder/\\"&gt;Ссылка&lt;/a&gt;&lt;br /&gt;/n&lt;a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\"&gt;Внешняя ссылка&lt;/a&gt;&lt;/p&gt;/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"ru/page2","vcsPath":"ru/page2.md"},"headings":[{"title":"хэш","href":"ru/page2#hesh","level":2}],"title":"Страница 2"},"router":{"pathname":"ru/page2","depth":2,"base":"../"},"lang":"ru","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
506
506
  </script>
507
507
  <script type="application/javascript">
508
508
  const data = document.querySelector('script#diplodoc-state');
@@ -0,0 +1,55 @@
1
+ import {readFileSync, readdirSync} from 'node:fs';
2
+ import {join, sep} from 'node:path';
3
+ import {describe, expect, test} from 'vitest';
4
+
5
+ import {TestAdapter, getTestPaths} from '../fixtures';
6
+
7
+ function findHtmlFiles(dir: string): string[] {
8
+ const results: string[] = [];
9
+
10
+ try {
11
+ for (const entry of readdirSync(dir, {withFileTypes: true})) {
12
+ const full = join(dir, entry.name);
13
+
14
+ if (entry.isDirectory()) {
15
+ results.push(...findHtmlFiles(full));
16
+ } else if (entry.name.endsWith('.html')) {
17
+ results.push(full);
18
+ }
19
+ }
20
+ } catch {
21
+ // ignore
22
+ }
23
+
24
+ return results;
25
+ }
26
+
27
+ describe('disableCsp', () => {
28
+ test('should not inject CSP meta tag when disableCsp is true with neuroExpert enabled', async () => {
29
+ const {inputPath, outputPath} = getTestPaths('mocks/disable-csp');
30
+
31
+ await TestAdapter.testBuildPass(inputPath, outputPath, {
32
+ md2md: false,
33
+ md2html: true,
34
+ args: '-j2',
35
+ });
36
+
37
+ const htmlFiles = findHtmlFiles(outputPath);
38
+ expect(htmlFiles.length).toBeGreaterThan(0);
39
+
40
+ // No HTML page should contain CSP meta tag
41
+ for (const htmlFile of htmlFiles) {
42
+ const html = readFileSync(htmlFile, 'utf8');
43
+ expect(html).not.toContain('Content-Security-Policy');
44
+ }
45
+
46
+ // Content pages (under en/) should still have the neuroExpert widget script
47
+ const contentPages = htmlFiles.filter((f) => f.includes(`${sep}en${sep}`));
48
+ expect(contentPages.length).toBeGreaterThan(0);
49
+
50
+ for (const htmlFile of contentPages) {
51
+ const html = readFileSync(htmlFile, 'utf8');
52
+ expect(html).toContain('neuroexpert-widget');
53
+ }
54
+ });
55
+ });
@@ -52,4 +52,16 @@ describe('Include toc', () => {
52
52
  await TestAdapter.testBuildPass(inputPath, outputPath);
53
53
  await compareDirectories(outputPath);
54
54
  });
55
+
56
+ test('Toc with generic includer and linkIndex option', async () => {
57
+ const {inputPath, outputPath} = getTestPaths('mocks/include-toc/test8');
58
+ await TestAdapter.testBuildPass(inputPath, outputPath);
59
+ await compareDirectories(outputPath);
60
+ });
61
+
62
+ test('Toc with generic includer keeps index.md as child item by default', async () => {
63
+ const {inputPath, outputPath} = getTestPaths('mocks/include-toc/test9');
64
+ await TestAdapter.testBuildPass(inputPath, outputPath);
65
+ await compareDirectories(outputPath);
66
+ });
55
67
  });
@@ -0,0 +1,8 @@
1
+ allowHtml: true
2
+ langs: ['en']
3
+
4
+ disableCsp: true
5
+
6
+ neuroExpert:
7
+ projectId:
8
+ default: test-project-id
@@ -0,0 +1,3 @@
1
+ # Index
2
+
3
+ Content
@@ -0,0 +1,3 @@
1
+ # Page
2
+
3
+ Some content
@@ -0,0 +1,5 @@
1
+ title: DisableCSP
2
+ href: index.md
3
+ items:
4
+ - name: Page
5
+ href: page.md
@@ -0,0 +1,4 @@
1
+ # H1
2
+
3
+ [same level link](./test.md)
4
+ [inner link](./sub/sub-1.md)
@@ -0,0 +1 @@
1
+ # Sub index
@@ -0,0 +1,5 @@
1
+ # H1
2
+
3
+ [same level link](./sub-2.md)
4
+ [outer link](../test.md)
5
+ [inner link](./sub/sub-3.md)
@@ -0,0 +1,9 @@
1
+ title: main
2
+ items:
3
+ - include:
4
+ path: test
5
+ includers:
6
+ - name: generic
7
+ autotitle: false
8
+ input: test
9
+ linkIndex: true
@@ -0,0 +1,4 @@
1
+ # H1
2
+
3
+ [same level link](./test.md)
4
+ [inner link](./sub/sub-1.md)
@@ -0,0 +1 @@
1
+ # Sub index
@@ -0,0 +1,5 @@
1
+ # H1
2
+
3
+ [same level link](./sub-2.md)
4
+ [outer link](../test.md)
5
+ [inner link](./sub/sub-3.md)
@@ -0,0 +1,8 @@
1
+ title: main
2
+ items:
3
+ - include:
4
+ path: test
5
+ includers:
6
+ - name: generic
7
+ autotitle: false
8
+ input: test
@@ -0,0 +1,13 @@
1
+ ### Pdf ending page 1
2
+
3
+ Should be able to use variables {{test}}
4
+
5
+ Should be able to use link to other pages [test](../page1.md)
6
+
7
+ Should be able to use inlcudes
8
+
9
+ {% include [test-include](../__includes/include1.md) %}
10
+
11
+ Should be able to resolve liquid syntax
12
+
13
+ {% if test == "pdf" %} should be visible {% endif %}
@@ -0,0 +1,3 @@
1
+ <div class="pdf-title-page-wrapper">
2
+ <p>Lorem ipsum ending page with var {{test}}</p>
3
+ </div>
@@ -4,6 +4,9 @@ pdf:
4
4
  startPages:
5
5
  - ./pdf-titles/pdf-title-page1.md
6
6
  - ./pdf-titles/pdf-title-page2.md
7
+ endPages:
8
+ - ./pdf-endings/pdf-ending-page1.md
9
+ - ./pdf-endings/pdf-ending-page2.md
7
10
 
8
11
  items:
9
12
  - name: Title 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "5.28.0",
3
+ "version": "5.30.0",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },