@diplodoc/cli 5.46.1 → 5.47.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/build/index.js +3 -3
- package/build/index.mjs +3 -3
- package/package.json +24 -8
- package/tests/.eslintrc.js +9 -0
- package/tests/e2e/__snapshots__/alternates.test.ts.snap +1199 -0
- package/tests/e2e/__snapshots__/assets.spec.ts.snap +0 -0
- package/tests/e2e/__snapshots__/build-content-map.spec.ts.snap +329 -0
- package/tests/e2e/__snapshots__/bundles.spec.ts.snap +172 -0
- package/tests/e2e/__snapshots__/cleanup-empty-dirs.spec.ts.snap +65 -0
- package/tests/e2e/__snapshots__/crawler-manifest.spec.ts.snap +28 -0
- package/tests/e2e/__snapshots__/files.spec.ts.snap +164 -0
- package/tests/e2e/__snapshots__/files.test.ts.snap +146 -0
- package/tests/e2e/__snapshots__/generate-map.spec.ts.snap +408 -0
- package/tests/e2e/__snapshots__/include-toc.test.ts.snap +797 -0
- package/tests/e2e/__snapshots__/include-with-meta.test.ts.snap +67 -0
- package/tests/e2e/__snapshots__/includes-conditions.test.ts.snap +78 -0
- package/tests/e2e/__snapshots__/includes.test.ts.snap +780 -0
- package/tests/e2e/__snapshots__/init.test.ts.snap +283 -0
- package/tests/e2e/__snapshots__/llms.spec.ts.snap +257 -0
- package/tests/e2e/__snapshots__/load-custom-resources.spec.ts.snap +362 -0
- package/tests/e2e/__snapshots__/markdown-options.spec.ts.snap +209 -0
- package/tests/e2e/__snapshots__/merge-includes.spec.ts.snap +1058 -0
- package/tests/e2e/__snapshots__/metadata.spec.ts.snap +200 -0
- package/tests/e2e/__snapshots__/neuro-expert.test.ts.snap +625 -0
- package/tests/e2e/__snapshots__/pdf-page.spec.ts.snap +341 -0
- package/tests/e2e/__snapshots__/plugin-corner-cases.spec.ts.snap +0 -0
- package/tests/e2e/__snapshots__/preprocess.test.ts.snap +1558 -0
- package/tests/e2e/__snapshots__/regression.test.ts.snap +2033 -0
- package/tests/e2e/__snapshots__/restricted-access.test.ts.snap +244 -0
- package/tests/e2e/__snapshots__/rtl.spec.ts.snap +234 -0
- package/tests/e2e/__snapshots__/search.test.ts.snap +56 -0
- package/tests/e2e/__snapshots__/single-page.spec.ts.snap +163 -0
- package/tests/e2e/__snapshots__/skip-html-extension.spec.ts.snap +519 -0
- package/tests/e2e/__snapshots__/toc-label.test.ts.snap +127 -0
- package/tests/e2e/__snapshots__/translation.spec.ts.snap +2386 -0
- package/tests/e2e/__snapshots__/vars-conditions.spec.ts.snap +131 -0
- package/tests/e2e/alternates.test.ts +49 -0
- package/tests/e2e/assets.spec.ts +31 -0
- package/tests/e2e/autotitles.spec.ts +37 -0
- package/tests/e2e/build-content-map.spec.ts +220 -0
- package/tests/e2e/bundles.spec.ts +16 -0
- package/tests/e2e/cleanup-empty-dirs.spec.ts +59 -0
- package/tests/e2e/crawler-manifest.spec.ts +129 -0
- package/tests/e2e/disable-csp.spec.ts +55 -0
- package/tests/e2e/empty-presets.spec.ts +32 -0
- package/tests/e2e/errors.spec.ts +158 -0
- package/tests/e2e/files.spec.ts +21 -0
- package/tests/e2e/generate-map.spec.ts +47 -0
- package/tests/e2e/include-toc.test.ts +73 -0
- package/tests/e2e/include-with-meta.test.ts +20 -0
- package/tests/e2e/includes-conditions.test.ts +23 -0
- package/tests/e2e/includes.test.ts +52 -0
- package/tests/e2e/init.test.ts +105 -0
- package/tests/e2e/llms.spec.ts +24 -0
- package/tests/e2e/load-custom-resources.spec.ts +23 -0
- package/tests/e2e/markdown-options.spec.ts +17 -0
- package/tests/e2e/merge-includes.spec.ts +196 -0
- package/tests/e2e/metadata.spec.ts +79 -0
- package/tests/e2e/nested-include-links.spec.ts +26 -0
- package/tests/e2e/neuro-expert.test.ts +16 -0
- package/tests/e2e/openapi-companion.spec.ts +213 -0
- package/tests/e2e/openapi-include-size.spec.ts +55 -0
- package/tests/e2e/pdf-page.spec.ts +127 -0
- package/tests/e2e/plugin-corner-cases.spec.ts +14 -0
- package/tests/e2e/preprocess.test.ts +40 -0
- package/tests/e2e/redirects-validation.spec.ts +62 -0
- package/tests/e2e/regression.test.ts +39 -0
- package/tests/e2e/restricted-access.test.ts +19 -0
- package/tests/e2e/rtl.spec.ts +17 -0
- package/tests/e2e/search.test.ts +16 -0
- package/tests/e2e/single-page.spec.ts +23 -0
- package/tests/e2e/skip-html-extension.spec.ts +17 -0
- package/tests/e2e/themer.test.ts +307 -0
- package/tests/e2e/toc-label.test.ts +23 -0
- package/tests/e2e/translation.spec.ts +221 -0
- package/tests/e2e/vars-conditions.spec.ts +16 -0
- package/tests/e2e/vars-ignore.test.ts +168 -0
- package/tests/fixtures/cli.ts +103 -0
- package/tests/fixtures/file.ts +148 -0
- package/tests/fixtures/globals.d.ts +4 -0
- package/tests/fixtures/index.ts +4 -0
- package/tests/fixtures/runner.ts +49 -0
- package/tests/fixtures/test.ts +210 -0
- package/tests/mocks/alternates/input/.yfm +1 -0
- package/tests/mocks/alternates/input/az/about.md +3 -0
- package/tests/mocks/alternates/input/az/deep/test.md +3 -0
- package/tests/mocks/alternates/input/az/index.yaml +3 -0
- package/tests/mocks/alternates/input/az/toc.yaml +6 -0
- package/tests/mocks/alternates/input/en/about.md +3 -0
- package/tests/mocks/alternates/input/en/deep/test.md +3 -0
- package/tests/mocks/alternates/input/en/index.yaml +3 -0
- package/tests/mocks/alternates/input/en/toc.yaml +6 -0
- package/tests/mocks/alternates/input/ru/about.md +8 -0
- package/tests/mocks/alternates/input/ru/deep/test.md +3 -0
- package/tests/mocks/alternates/input/ru/index.yaml +3 -0
- package/tests/mocks/alternates/input/ru/toc.yaml +6 -0
- package/tests/mocks/assets/input/.yfm +1 -0
- package/tests/mocks/assets/input/_images/camera.svg +1 -0
- package/tests/mocks/assets/input/_images/icons/bulb.svg +1 -0
- package/tests/mocks/assets/input/_images/mountain.jpg +0 -0
- package/tests/mocks/assets/input/_images/versions.png +0 -0
- package/tests/mocks/assets/input/index.md +18 -0
- package/tests/mocks/assets/input/page.yaml +7 -0
- package/tests/mocks/assets/input/toc.yaml +7 -0
- package/tests/mocks/autotitles/input/docs/index.md +3 -0
- package/tests/mocks/autotitles/input/docs/target.md +3 -0
- package/tests/mocks/autotitles/input/toc.yaml +5 -0
- package/tests/mocks/build-content-map/autotitle-chain/input/.yfm +0 -0
- package/tests/mocks/build-content-map/autotitle-chain/input/a.md +3 -0
- package/tests/mocks/build-content-map/autotitle-chain/input/b.md +3 -0
- package/tests/mocks/build-content-map/autotitle-chain/input/c.md +3 -0
- package/tests/mocks/build-content-map/autotitle-chain/input/toc.yaml +9 -0
- package/tests/mocks/build-content-map/autotitle-target-with-include/input/.yfm +0 -0
- package/tests/mocks/build-content-map/autotitle-target-with-include/input/_includes/snippet.md +3 -0
- package/tests/mocks/build-content-map/autotitle-target-with-include/input/a.md +3 -0
- package/tests/mocks/build-content-map/autotitle-target-with-include/input/b.md +3 -0
- package/tests/mocks/build-content-map/autotitle-target-with-include/input/toc.yaml +7 -0
- package/tests/mocks/build-content-map/diamond-includes/input/.yfm +0 -0
- package/tests/mocks/build-content-map/diamond-includes/input/_includes/branch-a.md +5 -0
- package/tests/mocks/build-content-map/diamond-includes/input/_includes/branch-b.md +5 -0
- package/tests/mocks/build-content-map/diamond-includes/input/_includes/shared.md +3 -0
- package/tests/mocks/build-content-map/diamond-includes/input/index.md +7 -0
- package/tests/mocks/build-content-map/diamond-includes/input/toc.yaml +5 -0
- package/tests/mocks/build-content-map/nested-includes/input/.yfm +0 -0
- package/tests/mocks/build-content-map/nested-includes/input/_includes/level1.md +5 -0
- package/tests/mocks/build-content-map/nested-includes/input/_includes/level2.md +3 -0
- package/tests/mocks/build-content-map/nested-includes/input/index.md +5 -0
- package/tests/mocks/build-content-map/nested-includes/input/toc.yaml +5 -0
- package/tests/mocks/build-content-map/with-autotitles/input/.yfm +0 -0
- package/tests/mocks/build-content-map/with-autotitles/input/index.md +3 -0
- package/tests/mocks/build-content-map/with-autotitles/input/other.md +3 -0
- package/tests/mocks/build-content-map/with-autotitles/input/toc.yaml +7 -0
- package/tests/mocks/build-content-map/with-includes/input/.yfm +0 -0
- package/tests/mocks/build-content-map/with-includes/input/_includes/snippet.md +1 -0
- package/tests/mocks/build-content-map/with-includes/input/index.md +5 -0
- package/tests/mocks/build-content-map/with-includes/input/logo.svg +1 -0
- package/tests/mocks/build-content-map/with-includes/input/toc.yaml +5 -0
- package/tests/mocks/bundles/input/.yfm +13 -0
- package/tests/mocks/bundles/input/index.md +12 -0
- package/tests/mocks/bundles/input/page1.md +3 -0
- package/tests/mocks/bundles/input/page2.md +5 -0
- package/tests/mocks/bundles/input/toc.yaml +9 -0
- package/tests/mocks/cleanup-empty-dirs/input/.yfm +2 -0
- package/tests/mocks/cleanup-empty-dirs/input/active/page.md +5 -0
- package/tests/mocks/cleanup-empty-dirs/input/active/presets.yaml +2 -0
- package/tests/mocks/cleanup-empty-dirs/input/active/toc.yaml +4 -0
- package/tests/mocks/cleanup-empty-dirs/input/empty-section/page.md +5 -0
- package/tests/mocks/cleanup-empty-dirs/input/empty-section/presets.yaml +2 -0
- package/tests/mocks/cleanup-empty-dirs/input/empty-section/toc.yaml +5 -0
- package/tests/mocks/cleanup-empty-dirs/input/index.md +5 -0
- package/tests/mocks/cleanup-empty-dirs/input/presets.yaml +2 -0
- package/tests/mocks/cleanup-empty-dirs/input/toc.yaml +5 -0
- package/tests/mocks/crawler-manifest/config/input/.yfm +1 -0
- package/tests/mocks/crawler-manifest/config/input/index.md +3 -0
- package/tests/mocks/crawler-manifest/config/input/toc.yaml +4 -0
- package/tests/mocks/crawler-manifest/exclude/input/.yfm +9 -0
- package/tests/mocks/crawler-manifest/exclude/input/index.md +5 -0
- package/tests/mocks/crawler-manifest/exclude/input/toc.yaml +4 -0
- package/tests/mocks/crawler-manifest/no-links/input/index.md +5 -0
- package/tests/mocks/crawler-manifest/no-links/input/toc.yaml +4 -0
- package/tests/mocks/crawler-manifest/notifications-docs-viewer/input/.yfm +8 -0
- package/tests/mocks/crawler-manifest/notifications-docs-viewer/input/index.md +3 -0
- package/tests/mocks/crawler-manifest/notifications-docs-viewer/input/toc.yaml +4 -0
- package/tests/mocks/crawler-manifest/notifications-no-receivers/input/.yfm +5 -0
- package/tests/mocks/crawler-manifest/notifications-no-receivers/input/index.md +3 -0
- package/tests/mocks/crawler-manifest/notifications-no-receivers/input/toc.yaml +4 -0
- package/tests/mocks/crawler-manifest/notifications-root/input/.yfm +11 -0
- package/tests/mocks/crawler-manifest/notifications-root/input/index.md +3 -0
- package/tests/mocks/crawler-manifest/notifications-root/input/toc.yaml +4 -0
- package/tests/mocks/crawler-manifest/with-links/input/redirects.yaml +5 -0
- package/tests/mocks/crawler-manifest/with-links/input/ru/_includes/snippet.md +1 -0
- package/tests/mocks/crawler-manifest/with-links/input/ru/index.md +35 -0
- package/tests/mocks/crawler-manifest/with-links/input/ru/leading.yaml +5 -0
- package/tests/mocks/crawler-manifest/with-links/input/ru/no-links.md +3 -0
- package/tests/mocks/crawler-manifest/with-links/input/ru/references.md +5 -0
- package/tests/mocks/crawler-manifest/with-links/input/toc.yaml +12 -0
- package/tests/mocks/disable-csp/input/.yfm +8 -0
- package/tests/mocks/disable-csp/input/en/index.md +3 -0
- package/tests/mocks/disable-csp/input/en/page.md +3 -0
- package/tests/mocks/disable-csp/input/en/toc.yaml +5 -0
- package/tests/mocks/docs-viewer-interface/input/.yfm +6 -0
- package/tests/mocks/docs-viewer-interface/input/index.md +3 -0
- package/tests/mocks/docs-viewer-interface/input/toc.yaml +5 -0
- package/tests/mocks/empty-presets/input/.yfm +1 -0
- package/tests/mocks/empty-presets/input/index.md +3 -0
- package/tests/mocks/empty-presets/input/presets.yaml +3 -0
- package/tests/mocks/empty-presets/input/subfolder/presets.yaml +3 -0
- package/tests/mocks/empty-presets/input/subfolder/subpage.md +3 -0
- package/tests/mocks/empty-presets/input/subfolder/toc.yaml +4 -0
- package/tests/mocks/empty-presets/input/toc.yaml +4 -0
- package/tests/mocks/errors/extract-filtered-link/input/filtered.md +1 -0
- package/tests/mocks/errors/extract-filtered-link/input/filtered2.md +0 -0
- package/tests/mocks/errors/extract-filtered-link/input/index.md +7 -0
- package/tests/mocks/errors/extract-filtered-link/input/toc.yaml +1 -0
- package/tests/mocks/errors/invalid-frontmatter/input/index.md +9 -0
- package/tests/mocks/errors/invalid-frontmatter/input/toc.yaml +1 -0
- package/tests/mocks/errors/invalid-toc-entry-href/input/.yfm +1 -0
- package/tests/mocks/errors/invalid-toc-entry-href/input/ru/toc.yaml +3 -0
- package/tests/mocks/errors/invalid-toc-root-array/input/.yfm +1 -0
- package/tests/mocks/errors/invalid-toc-root-array/input/ru/toc.yaml +2 -0
- package/tests/mocks/errors/max-asset-size/input/_images/large-image.png +0 -0
- package/tests/mocks/errors/max-asset-size/input/index.md +5 -0
- package/tests/mocks/errors/max-asset-size/input/toc.yaml +1 -0
- package/tests/mocks/errors/object-validation/input/index.md +3 -0
- package/tests/mocks/errors/object-validation/input/toc.yaml +14 -0
- package/tests/mocks/errors/unreachable-link/input/exists.md +1 -0
- package/tests/mocks/errors/unreachable-link/input/index.md +2 -0
- package/tests/mocks/errors/unreachable-link/input/toc.yaml +1 -0
- package/tests/mocks/errors/unreachable-link-in-include/input/_includes/chapter.md +1 -0
- package/tests/mocks/errors/unreachable-link-in-include/input/index.md +5 -0
- package/tests/mocks/errors/unreachable-link-in-include/input/toc.yaml +1 -0
- package/tests/mocks/errors/unreachable-link-in-nested-include/input/_includes/chapter.md +3 -0
- package/tests/mocks/errors/unreachable-link-in-nested-include/input/_includes/details.md +1 -0
- package/tests/mocks/errors/unreachable-link-in-nested-include/input/index.md +3 -0
- package/tests/mocks/errors/unreachable-link-in-nested-include/input/toc.yaml +1 -0
- package/tests/mocks/errors/valid-link-in-include/input/_includes/content.md +1 -0
- package/tests/mocks/errors/valid-link-in-include/input/index.md +3 -0
- package/tests/mocks/errors/valid-link-in-include/input/page.md +3 -0
- package/tests/mocks/errors/valid-link-in-include/input/toc.yaml +4 -0
- package/tests/mocks/fileContent/metadata/authorAliasInMetadata.md +7 -0
- package/tests/mocks/fileContent/metadata/fullAuthorInMetadata.md +10 -0
- package/tests/mocks/fileContent/metadata/includesContent/firstIncludeFile.md +7 -0
- package/tests/mocks/fileContent/metadata/includesContent/secondIncludeFile.md +5 -0
- package/tests/mocks/fileContent/metadata/includesContent/withIncludes.md +7 -0
- package/tests/mocks/fileContent/metadata/keywordsInMetadata.md +9 -0
- package/tests/mocks/fileContent/metadata/simpleMetadata.md +6 -0
- package/tests/mocks/fileContent/metadata/substitutionsInMetadataPropertyKeys.md +7 -0
- package/tests/mocks/fileContent/metadata/substitutionsInMetadataPropertyValues.md +11 -0
- package/tests/mocks/fileContent/metadata/substitutionsWithEmptyString.md +7 -0
- package/tests/mocks/fileContent/metadata/variableInMetadata.md +7 -0
- package/tests/mocks/fileContent/metadata/withAdditionalSeparatorsInContent.md +9 -0
- package/tests/mocks/fileContent/metadata/withoutMetadata.md +2 -0
- package/tests/mocks/fileContent/metadata/withoutMetadataWithAdditionalSeparatorsInContent.md +6 -0
- package/tests/mocks/files/input/_assets/test.csv +0 -0
- package/tests/mocks/files/input/_assets/test.docx +0 -0
- package/tests/mocks/files/input/_assets/test.pdf +0 -0
- package/tests/mocks/files/input/_assets/test.pptx +0 -0
- package/tests/mocks/files/input/_assets/test.txt +0 -0
- package/tests/mocks/files/input/_assets/test.xlsx +0 -0
- package/tests/mocks/files/input/_assets/test.yaml +50 -0
- package/tests/mocks/files/input/index.md +17 -0
- package/tests/mocks/files/input/pc-index.yaml +70 -0
- package/tests/mocks/files/input/toc.yaml +6 -0
- package/tests/mocks/generate-map/test1/input/.yfm +0 -0
- package/tests/mocks/generate-map/test1/input/ru/_includes/file.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/_includes/plugins.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/folder1/a1.md +1 -0
- package/tests/mocks/generate-map/test1/input/ru/folder1/folder2/a1.md +1 -0
- package/tests/mocks/generate-map/test1/input/ru/folder1/folder2/toc.yaml +5 -0
- package/tests/mocks/generate-map/test1/input/ru/folder1/toc.yaml +7 -0
- package/tests/mocks/generate-map/test1/input/ru/index.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/plugins/import.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/plugins/index.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/project/config.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/project/index.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/settings.md +0 -0
- package/tests/mocks/generate-map/test1/input/ru/toc.yaml +22 -0
- package/tests/mocks/generate-map/test2/input/en/_includes/file.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/_includes/plugins.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/index.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/plugins/import.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/plugins/index.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/project/config.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/project/index.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/settings.md +0 -0
- package/tests/mocks/generate-map/test2/input/en/toc.yaml +18 -0
- package/tests/mocks/generate-map/test2/input/ru/_includes/file.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/_includes/plugins.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/index.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/plugins/import.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/plugins/index.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/project/config.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/project/index.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/settings.md +0 -0
- package/tests/mocks/generate-map/test2/input/ru/toc.yaml +18 -0
- package/tests/mocks/generate-map/test3/input/.yfm +0 -0
- package/tests/mocks/generate-map/test3/input/ru/_includes/file.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/_includes/plugins.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/folder1/a1.md +1 -0
- package/tests/mocks/generate-map/test3/input/ru/folder1/folder2/a1.md +1 -0
- package/tests/mocks/generate-map/test3/input/ru/folder1/folder2/toc.yaml +5 -0
- package/tests/mocks/generate-map/test3/input/ru/folder1/toc.yaml +7 -0
- package/tests/mocks/generate-map/test3/input/ru/index.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/plugins/import.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/plugins/index.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/project/config.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/project/index.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/settings.md +0 -0
- package/tests/mocks/generate-map/test3/input/ru/toc.yaml +22 -0
- package/tests/mocks/include-skip/test1/input/includes/missing.md +1 -0
- package/tests/mocks/include-skip/test1/input/index.md +3 -0
- package/tests/mocks/include-skip/test1/input/toc.yaml +3 -0
- package/tests/mocks/include-skip/test2/input/includes/missing.md +1 -0
- package/tests/mocks/include-skip/test2/input/includes/valid.md +4 -0
- package/tests/mocks/include-skip/test2/input/index.md +4 -0
- package/tests/mocks/include-skip/test2/input/toc.yaml +4 -0
- package/tests/mocks/include-toc/test1/input/a1.md +1 -0
- package/tests/mocks/include-toc/test1/input/folder1/a1.md +1 -0
- package/tests/mocks/include-toc/test1/input/folder1/folder2/a1.md +1 -0
- package/tests/mocks/include-toc/test1/input/folder1/folder2/toc.yaml +5 -0
- package/tests/mocks/include-toc/test1/input/folder1/toc.yaml +7 -0
- package/tests/mocks/include-toc/test1/input/toc.yaml +9 -0
- package/tests/mocks/include-toc/test10/input/test/index.md +4 -0
- package/tests/mocks/include-toc/test10/input/test/sub/index.md +1 -0
- package/tests/mocks/include-toc/test10/input/test/sub/sub/sub-3.md +1 -0
- package/tests/mocks/include-toc/test10/input/test/sub/sub-1.md +5 -0
- package/tests/mocks/include-toc/test10/input/test/sub/sub-2.md +1 -0
- package/tests/mocks/include-toc/test10/input/test/test.md +1 -0
- package/tests/mocks/include-toc/test10/input/toc.yaml +9 -0
- package/tests/mocks/include-toc/test2/input/.yfm +1 -0
- package/tests/mocks/include-toc/test2/input/file1.md +1 -0
- package/tests/mocks/include-toc/test2/input/fileX.md +1 -0
- package/tests/mocks/include-toc/test2/input/folder/fileA.md +11 -0
- package/tests/mocks/include-toc/test2/input/folder/fileB.md +9 -0
- package/tests/mocks/include-toc/test2/input/folder/folder/fileC.md +1 -0
- package/tests/mocks/include-toc/test2/input/folder/folder/toc.yaml +3 -0
- package/tests/mocks/include-toc/test2/input/folder/toc.yaml +6 -0
- package/tests/mocks/include-toc/test2/input/presets.yaml +2 -0
- package/tests/mocks/include-toc/test2/input/toc.yaml +6 -0
- package/tests/mocks/include-toc/test3/input/product1/core/_includes/inc.md +1 -0
- package/tests/mocks/include-toc/test3/input/product1/core/article1.md +3 -0
- package/tests/mocks/include-toc/test3/input/product1/core/toc_m.yaml +2 -0
- package/tests/mocks/include-toc/test3/input/product1/product/toc_p.yaml +3 -0
- package/tests/mocks/include-toc/test3/input/product1/toc.yaml +3 -0
- package/tests/mocks/include-toc/test3/input/product2/core/_includes/inc.md +1 -0
- package/tests/mocks/include-toc/test3/input/product2/core/article1.md +3 -0
- package/tests/mocks/include-toc/test3/input/product2/core/toc_m.yaml +2 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay1/product/article1.md +3 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay1/product/toc_p.yaml +3 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay1/toc.yaml +2 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay2/product/article1.md +3 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay2/product/toc_p.yaml +3 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay2/toc.yaml +2 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay3/product/toc_p.yaml +3 -0
- package/tests/mocks/include-toc/test3/input/product2/overlay3/toc.yaml +2 -0
- package/tests/mocks/include-toc/test3/input/product2/p2.md +4 -0
- package/tests/mocks/include-toc/test3/input/product2/toc.yaml +10 -0
- package/tests/mocks/include-toc/test4/input/a1.md +1 -0
- package/tests/mocks/include-toc/test4/input/index.yaml +20 -0
- package/tests/mocks/include-toc/test4/input/toc.yaml +9 -0
- package/tests/mocks/include-toc/test5/input/core/concepts/toc_i.yaml +2 -0
- package/tests/mocks/include-toc/test5/input/core/concepts/toc_p.yaml +3 -0
- package/tests/mocks/include-toc/test5/input/core/toc_i.yaml +6 -0
- package/tests/mocks/include-toc/test5/input/core/toc_m.yaml +3 -0
- package/tests/mocks/include-toc/test5/input/core/toc_p.yaml +5 -0
- package/tests/mocks/include-toc/test5/input/overlay/toc_p.yaml +3 -0
- package/tests/mocks/include-toc/test5/input/toc.yaml +4 -0
- package/tests/mocks/include-toc/test6/input/test/index.md +4 -0
- package/tests/mocks/include-toc/test6/input/test/sub/sub/sub-3.md +1 -0
- package/tests/mocks/include-toc/test6/input/test/sub/sub-1.md +5 -0
- package/tests/mocks/include-toc/test6/input/test/sub/sub-2.md +1 -0
- package/tests/mocks/include-toc/test6/input/test/test.md +1 -0
- package/tests/mocks/include-toc/test6/input/toc.yaml +8 -0
- package/tests/mocks/include-toc/test7/input/.yfm +1 -0
- package/tests/mocks/include-toc/test7/input/ru/presets.yaml +2 -0
- package/tests/mocks/include-toc/test7/input/ru/sub/folder/index.yaml +4 -0
- package/tests/mocks/include-toc/test7/input/ru/sub/folder/toc.yaml +3 -0
- package/tests/mocks/include-toc/test7/input/ru/toc.yaml +3 -0
- package/tests/mocks/include-toc/test8/input/test/index.md +4 -0
- package/tests/mocks/include-toc/test8/input/test/sub/index.md +1 -0
- package/tests/mocks/include-toc/test8/input/test/sub/sub/sub-3.md +1 -0
- package/tests/mocks/include-toc/test8/input/test/sub/sub-1.md +5 -0
- package/tests/mocks/include-toc/test8/input/test/sub/sub-2.md +1 -0
- package/tests/mocks/include-toc/test8/input/test/test.md +1 -0
- package/tests/mocks/include-toc/test8/input/toc.yaml +9 -0
- package/tests/mocks/include-toc/test9/input/test/index.md +4 -0
- package/tests/mocks/include-toc/test9/input/test/sub/index.md +1 -0
- package/tests/mocks/include-toc/test9/input/test/sub/sub/sub-3.md +1 -0
- package/tests/mocks/include-toc/test9/input/test/sub/sub-1.md +5 -0
- package/tests/mocks/include-toc/test9/input/test/sub/sub-2.md +1 -0
- package/tests/mocks/include-toc/test9/input/test/test.md +1 -0
- package/tests/mocks/include-toc/test9/input/toc.yaml +8 -0
- package/tests/mocks/include-with-meta/input/included.md +16 -0
- package/tests/mocks/include-with-meta/input/index.md +15 -0
- package/tests/mocks/include-with-meta/input/toc.yaml +6 -0
- package/tests/mocks/includes/input/.yfm +1 -0
- package/tests/mocks/includes/input/_assets/4.png +0 -0
- package/tests/mocks/includes/input/includes/commented-include.md +5 -0
- package/tests/mocks/includes/input/includes/deep-include.md +13 -0
- package/tests/mocks/includes/input/includes/fragments.md +23 -0
- package/tests/mocks/includes/input/includes/nested-include.md +5 -0
- package/tests/mocks/includes/input/includes/no-title-include.md +19 -0
- package/tests/mocks/includes/input/includes/root-include.md +11 -0
- package/tests/mocks/includes/input/includes/user.md +5 -0
- package/tests/mocks/includes/input/index.md +69 -0
- package/tests/mocks/includes/input/level1/includes/level1-include.md +11 -0
- package/tests/mocks/includes/input/level1/level2/includes/level2-include.md +11 -0
- package/tests/mocks/includes/input/level1/level2/page2.md +29 -0
- package/tests/mocks/includes/input/level1/page1.md +29 -0
- package/tests/mocks/includes/input/presets.yaml +3 -0
- package/tests/mocks/includes/input/toc-include.md +13 -0
- package/tests/mocks/includes/input/toc.yaml +13 -0
- package/tests/mocks/includes-conditions/input/includes/first.md +5 -0
- package/tests/mocks/includes-conditions/input/includes/second.md +5 -0
- package/tests/mocks/includes-conditions/input/includes/third.md +1 -0
- package/tests/mocks/includes-conditions/input/index.md +7 -0
- package/tests/mocks/includes-conditions/input/presets.yaml +2 -0
- package/tests/mocks/includes-conditions/input/toc.yaml +3 -0
- package/tests/mocks/includes-missing/input/index.md +7 -0
- package/tests/mocks/includes-missing/input/toc.yaml +3 -0
- package/tests/mocks/llms/input/.yfm +1 -0
- package/tests/mocks/llms/input/_includes/requirements.md +4 -0
- package/tests/mocks/llms/input/api.md +9 -0
- package/tests/mocks/llms/input/beta.md +4 -0
- package/tests/mocks/llms/input/index.md +8 -0
- package/tests/mocks/llms/input/presets.yaml +2 -0
- package/tests/mocks/llms/input/start.md +9 -0
- package/tests/mocks/llms/input/toc.yaml +11 -0
- package/tests/mocks/load-custom-resources/md2html-with-resources/input/.yfm +5 -0
- package/tests/mocks/load-custom-resources/md2html-with-resources/input/_assets/script/test1.js +0 -0
- package/tests/mocks/load-custom-resources/md2html-with-resources/input/_assets/style/test.css +13 -0
- package/tests/mocks/load-custom-resources/md2html-with-resources/input/index.yaml +9 -0
- package/tests/mocks/load-custom-resources/md2html-with-resources/input/page.md +14 -0
- package/tests/mocks/load-custom-resources/md2html-with-resources/input/project/config.md +1 -0
- package/tests/mocks/load-custom-resources/md2html-with-resources/input/toc.yaml +7 -0
- package/tests/mocks/load-custom-resources/md2md-with-resources/input/.yfm +5 -0
- package/tests/mocks/load-custom-resources/md2md-with-resources/input/_assets/script/test1.js +0 -0
- package/tests/mocks/load-custom-resources/md2md-with-resources/input/_assets/style/test.css +13 -0
- package/tests/mocks/load-custom-resources/md2md-with-resources/input/index.yaml +9 -0
- package/tests/mocks/load-custom-resources/md2md-with-resources/input/page.md +14 -0
- package/tests/mocks/load-custom-resources/md2md-with-resources/input/project/config.md +1 -0
- package/tests/mocks/load-custom-resources/md2md-with-resources/input/toc.yaml +7 -0
- package/tests/mocks/load-custom-resources/single-page-with-resources/input/.yfm +5 -0
- package/tests/mocks/load-custom-resources/single-page-with-resources/input/_assets/script/test1.js +0 -0
- package/tests/mocks/load-custom-resources/single-page-with-resources/input/_assets/style/test.css +13 -0
- package/tests/mocks/load-custom-resources/single-page-with-resources/input/index.yaml +9 -0
- package/tests/mocks/load-custom-resources/single-page-with-resources/input/page.md +14 -0
- package/tests/mocks/load-custom-resources/single-page-with-resources/input/project/config.md +1 -0
- package/tests/mocks/load-custom-resources/single-page-with-resources/input/toc.yaml +7 -0
- package/tests/mocks/markdown-options/example-1/input/.yfm +5 -0
- package/tests/mocks/markdown-options/example-1/input/breaks.md +5 -0
- package/tests/mocks/markdown-options/example-1/input/linkify-tlds.md +7 -0
- package/tests/mocks/markdown-options/example-1/input/linkify.md +3 -0
- package/tests/mocks/markdown-options/example-1/input/toc.yaml +7 -0
- package/tests/mocks/markdown-options/example-2/input/.yfm +3 -0
- package/tests/mocks/markdown-options/example-2/input/breaks.md +5 -0
- package/tests/mocks/markdown-options/example-2/input/linkify-tlds.md +7 -0
- package/tests/mocks/markdown-options/example-2/input/linkify.md +3 -0
- package/tests/mocks/markdown-options/example-2/input/toc.yaml +7 -0
- package/tests/mocks/merge-includes/basic/input/_includes/simple.md +3 -0
- package/tests/mocks/merge-includes/basic/input/index.md +3 -0
- package/tests/mocks/merge-includes/basic/input/main.md +7 -0
- package/tests/mocks/merge-includes/basic/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/hash-fallback/input/_includes/sections.md +19 -0
- package/tests/mocks/merge-includes/hash-fallback/input/index.md +1 -0
- package/tests/mocks/merge-includes/hash-fallback/input/main.md +5 -0
- package/tests/mocks/merge-includes/hash-fallback/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/hash-section-html/input/_includes/mixed.md +11 -0
- package/tests/mocks/merge-includes/hash-section-html/input/index.md +3 -0
- package/tests/mocks/merge-includes/hash-section-html/input/main.md +13 -0
- package/tests/mocks/merge-includes/hash-section-html/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/html-comment-blanks/input/_includes/examples.md +27 -0
- package/tests/mocks/merge-includes/html-comment-blanks/input/index.md +3 -0
- package/tests/mocks/merge-includes/html-comment-blanks/input/main.md +15 -0
- package/tests/mocks/merge-includes/html-comment-blanks/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/html-in-list/input/_includes/styles.md +7 -0
- package/tests/mocks/merge-includes/html-in-list/input/index.md +3 -0
- package/tests/mocks/merge-includes/html-in-list/input/main.md +11 -0
- package/tests/mocks/merge-includes/html-in-list/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/include-after-fence/input/_includes/chat-button.md +1 -0
- package/tests/mocks/merge-includes/include-after-fence/input/_includes/footer.md +1 -0
- package/tests/mocks/merge-includes/include-after-fence/input/index.md +3 -0
- package/tests/mocks/merge-includes/include-after-fence/input/main.md +14 -0
- package/tests/mocks/merge-includes/include-after-fence/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/include-in-code-block/input/_includes/glossary.md +1 -0
- package/tests/mocks/merge-includes/include-in-code-block/input/index.md +3 -0
- package/tests/mocks/merge-includes/include-in-code-block/input/main.md +19 -0
- package/tests/mocks/merge-includes/include-in-code-block/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/indent-paragraph-in-include/input/_includes/requirements.md +9 -0
- package/tests/mocks/merge-includes/indent-paragraph-in-include/input/index.md +3 -0
- package/tests/mocks/merge-includes/indent-paragraph-in-include/input/main.md +12 -0
- package/tests/mocks/merge-includes/indent-paragraph-in-include/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/inline-context/input/_includes/snippet.md +12 -0
- package/tests/mocks/merge-includes/inline-context/input/index.md +3 -0
- package/tests/mocks/merge-includes/inline-context/input/main.md +11 -0
- package/tests/mocks/merge-includes/inline-context/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/nested/input/_includes/inner.md +3 -0
- package/tests/mocks/merge-includes/nested/input/_includes/outer.md +7 -0
- package/tests/mocks/merge-includes/nested/input/index.md +3 -0
- package/tests/mocks/merge-includes/nested/input/main.md +7 -0
- package/tests/mocks/merge-includes/nested/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/relative-paths/input/_includes/sub/with-links.md +7 -0
- package/tests/mocks/merge-includes/relative-paths/input/index.md +3 -0
- package/tests/mocks/merge-includes/relative-paths/input/main.md +3 -0
- package/tests/mocks/merge-includes/relative-paths/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/term-extract/input/_includes/chapter.md +7 -0
- package/tests/mocks/merge-includes/term-extract/input/index.md +3 -0
- package/tests/mocks/merge-includes/term-extract/input/main.md +7 -0
- package/tests/mocks/merge-includes/term-extract/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/term-inline/input/_includes/defs.md +20 -0
- package/tests/mocks/merge-includes/term-inline/input/index.md +3 -0
- package/tests/mocks/merge-includes/term-inline/input/main.md +19 -0
- package/tests/mocks/merge-includes/term-inline/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/yfm-table/input/_includes/cell-content.md +1 -0
- package/tests/mocks/merge-includes/yfm-table/input/index.md +3 -0
- package/tests/mocks/merge-includes/yfm-table/input/main.md +12 -0
- package/tests/mocks/merge-includes/yfm-table/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/yfm-table-html-block/input/_includes/button.md +8 -0
- package/tests/mocks/merge-includes/yfm-table-html-block/input/index.md +3 -0
- package/tests/mocks/merge-includes/yfm-table-html-block/input/main.md +12 -0
- package/tests/mocks/merge-includes/yfm-table-html-block/input/toc.yaml +5 -0
- package/tests/mocks/merge-includes/yfm-table-pipe-in-content/input/_includes/example.md +1 -0
- package/tests/mocks/merge-includes/yfm-table-pipe-in-content/input/index.md +3 -0
- package/tests/mocks/merge-includes/yfm-table-pipe-in-content/input/main.md +22 -0
- package/tests/mocks/merge-includes/yfm-table-pipe-in-content/input/toc.yaml +5 -0
- package/tests/mocks/metadata/include-with-csp-meta/input/.yfm +8 -0
- package/tests/mocks/metadata/include-with-csp-meta/input/_includes/support.md +1 -0
- package/tests/mocks/metadata/include-with-csp-meta/input/page.md +7 -0
- package/tests/mocks/metadata/include-with-csp-meta/input/toc.yaml +4 -0
- package/tests/mocks/metadata/md2html-with-metadata/input/.yfm +1 -0
- package/tests/mocks/metadata/md2html-with-metadata/input/index.yaml +9 -0
- package/tests/mocks/metadata/md2html-with-metadata/input/page.md +16 -0
- package/tests/mocks/metadata/md2html-with-metadata/input/presets.yaml +6 -0
- package/tests/mocks/metadata/md2html-with-metadata/input/project/config.md +7 -0
- package/tests/mocks/metadata/md2html-with-metadata/input/toc.yaml +7 -0
- package/tests/mocks/metadata/md2md-with-metadata/input/index.yaml +9 -0
- package/tests/mocks/metadata/md2md-with-metadata/input/page.md +14 -0
- package/tests/mocks/metadata/md2md-with-metadata/input/presets.yaml +6 -0
- package/tests/mocks/metadata/md2md-with-metadata/input/project/config.md +7 -0
- package/tests/mocks/metadata/md2md-with-metadata/input/toc.yaml +7 -0
- package/tests/mocks/nested-docs/input/.yfm +1 -0
- package/tests/mocks/nested-docs/input/.yfm-subdoc +5 -0
- package/tests/mocks/nested-docs/input/index.md +5 -0
- package/tests/mocks/nested-docs/input/presets.yaml +3 -0
- package/tests/mocks/nested-docs/input/subdoc/.yfm +0 -0
- package/tests/mocks/nested-docs/input/subdoc/index.md +5 -0
- package/tests/mocks/nested-docs/input/subdoc/presets.yaml +3 -0
- package/tests/mocks/nested-docs/input/subdoc/toc.yaml +4 -0
- package/tests/mocks/nested-docs/input/toc.yaml +6 -0
- package/tests/mocks/nested-include-links/input/includes/middle.md +4 -0
- package/tests/mocks/nested-include-links/input/other/page.md +4 -0
- package/tests/mocks/nested-include-links/input/sub/deep/entry.md +8 -0
- package/tests/mocks/nested-include-links/input/target.md +4 -0
- package/tests/mocks/nested-include-links/input/toc.yaml +6 -0
- package/tests/mocks/neuro-expert/input/.yfm +14 -0
- package/tests/mocks/neuro-expert/input/en/folder/index.md +1 -0
- package/tests/mocks/neuro-expert/input/en/index-test-html/index.md +4 -0
- package/tests/mocks/neuro-expert/input/en/index.md +11 -0
- package/tests/mocks/neuro-expert/input/en/page1.md +8 -0
- package/tests/mocks/neuro-expert/input/en/page2.md +6 -0
- package/tests/mocks/neuro-expert/input/en/toc.yaml +13 -0
- package/tests/mocks/neuro-expert/input/ru/folder/index.md +1 -0
- package/tests/mocks/neuro-expert/input/ru/index-test-html/index.md +4 -0
- package/tests/mocks/neuro-expert/input/ru/index.md +5 -0
- package/tests/mocks/neuro-expert/input/ru/page1.md +3 -0
- package/tests/mocks/neuro-expert/input/ru/page2.md +11 -0
- package/tests/mocks/neuro-expert/input/ru/toc.yaml +12 -0
- package/tests/mocks/openapi-companion/input/petstore.yaml +29 -0
- package/tests/mocks/openapi-companion/input/toc.yaml +9 -0
- package/tests/mocks/openapi-companion-disabled/input/.yfm +2 -0
- package/tests/mocks/openapi-companion-disabled/input/petstore.yaml +29 -0
- package/tests/mocks/openapi-companion-disabled/input/toc.yaml +9 -0
- package/tests/mocks/openapi-companion-link/input/petstore.yaml +29 -0
- package/tests/mocks/openapi-companion-link/input/toc.yaml +12 -0
- package/tests/mocks/openapi-include-size-exceeds/input/openapi-spec.yaml +190 -0
- package/tests/mocks/openapi-include-size-exceeds/input/toc.yaml +9 -0
- package/tests/mocks/openapi-include-size-within/input/openapi-spec.yaml +16 -0
- package/tests/mocks/openapi-include-size-within/input/toc.yaml +9 -0
- package/tests/mocks/pdf-page/custom-pdf-icon/input/.yfm +6 -0
- package/tests/mocks/pdf-page/custom-pdf-icon/input/_assets/custom-pdf-icon.svg +1 -0
- package/tests/mocks/pdf-page/custom-pdf-icon/input/index.md +1 -0
- package/tests/mocks/pdf-page/custom-pdf-icon/input/pdf/output.pdf +0 -0
- package/tests/mocks/pdf-page/custom-pdf-icon/input/toc.yaml +2 -0
- package/tests/mocks/pdf-page/flag-enabled/input/__includes/include1.md +3 -0
- package/tests/mocks/pdf-page/flag-enabled/input/index.md +7 -0
- package/tests/mocks/pdf-page/flag-enabled/input/page1.md +6 -0
- package/tests/mocks/pdf-page/flag-enabled/input/page2.md +7 -0
- package/tests/mocks/pdf-page/flag-enabled/input/page3.md +1 -0
- package/tests/mocks/pdf-page/flag-enabled/input/syntax/test.md +1 -0
- package/tests/mocks/pdf-page/flag-enabled/input/toc.yaml +17 -0
- package/tests/mocks/pdf-page/multiple-tocs/input/.yfm +2 -0
- package/tests/mocks/pdf-page/multiple-tocs/input/section1/index.md +5 -0
- package/tests/mocks/pdf-page/multiple-tocs/input/section1/page1.md +3 -0
- package/tests/mocks/pdf-page/multiple-tocs/input/section1/toc.yaml +6 -0
- package/tests/mocks/pdf-page/multiple-tocs/input/section2/index.md +5 -0
- package/tests/mocks/pdf-page/multiple-tocs/input/section2/page1.md +3 -0
- package/tests/mocks/pdf-page/multiple-tocs/input/section2/toc.yaml +6 -0
- package/tests/mocks/pdf-page/pc-page/input/__images/mountain.jpg +0 -0
- package/tests/mocks/pdf-page/pc-page/input/__includes/include1.md +1 -0
- package/tests/mocks/pdf-page/pc-page/input/index.md +1 -0
- package/tests/mocks/pdf-page/pc-page/input/index.yaml +87 -0
- package/tests/mocks/pdf-page/pc-page/input/index2.yaml +135 -0
- package/tests/mocks/pdf-page/pc-page/input/page1.md +3 -0
- package/tests/mocks/pdf-page/pc-page/input/page2.md +3 -0
- package/tests/mocks/pdf-page/pc-page/input/pdf-titles/pdf-title-page1.md +13 -0
- package/tests/mocks/pdf-page/pc-page/input/pdf-titles/pdf-title-page2.md +5 -0
- package/tests/mocks/pdf-page/pc-page/input/presets.yaml +2 -0
- package/tests/mocks/pdf-page/pc-page/input/toc.yaml +13 -0
- package/tests/mocks/pdf-page/pc-page/input/with-pc-page.md +363 -0
- package/tests/mocks/pdf-page/title-pages/input/.yfm +6 -0
- package/tests/mocks/pdf-page/title-pages/input/__assets/start-page.css +16 -0
- package/tests/mocks/pdf-page/title-pages/input/__images/mountain.jpg +0 -0
- package/tests/mocks/pdf-page/title-pages/input/__includes/include1.md +1 -0
- package/tests/mocks/pdf-page/title-pages/input/index.md +1 -0
- package/tests/mocks/pdf-page/title-pages/input/page1.md +3 -0
- package/tests/mocks/pdf-page/title-pages/input/page2.md +3 -0
- package/tests/mocks/pdf-page/title-pages/input/pdf-endings/pdf-ending-page1.md +13 -0
- package/tests/mocks/pdf-page/title-pages/input/pdf-endings/pdf-ending-page2.md +3 -0
- package/tests/mocks/pdf-page/title-pages/input/pdf-titles/pdf-title-page1.md +13 -0
- package/tests/mocks/pdf-page/title-pages/input/pdf-titles/pdf-title-page2.md +3 -0
- package/tests/mocks/pdf-page/title-pages/input/presets.yaml +2 -0
- package/tests/mocks/pdf-page/title-pages/input/toc.yaml +15 -0
- package/tests/mocks/pdf-page/yfm-config/input/.yfm +5 -0
- package/tests/mocks/pdf-page/yfm-config/input/index.md +6 -0
- package/tests/mocks/pdf-page/yfm-config/input/page1.md +3 -0
- package/tests/mocks/pdf-page/yfm-config/input/page2.md +7 -0
- package/tests/mocks/pdf-page/yfm-config/input/page3.md +1 -0
- package/tests/mocks/pdf-page/yfm-config/input/toc.yaml +15 -0
- package/tests/mocks/plugin-corner-cases/images-in-deflists/input/image.jpeg +0 -0
- package/tests/mocks/plugin-corner-cases/images-in-deflists/input/index.md +5 -0
- package/tests/mocks/plugin-corner-cases/images-in-deflists/input/toc.yaml +4 -0
- package/tests/mocks/preprocess/input/.yfm +1 -0
- package/tests/mocks/preprocess/input/1.md +29 -0
- package/tests/mocks/preprocess/input/_assets/1.png +0 -0
- package/tests/mocks/preprocess/input/_assets/1.svg +15 -0
- package/tests/mocks/preprocess/input/_assets/2.svg +19 -0
- package/tests/mocks/preprocess/input/autotitle.md +39 -0
- package/tests/mocks/preprocess/input/commented-include.md +3 -0
- package/tests/mocks/preprocess/input/images.md +163 -0
- package/tests/mocks/preprocess/input/included-item.md +12 -0
- package/tests/mocks/preprocess/input/includes/deep.md +1 -0
- package/tests/mocks/preprocess/input/includes/deepWithIndent.md +6 -0
- package/tests/mocks/preprocess/input/includes/level1.md +9 -0
- package/tests/mocks/preprocess/input/includes/level11.md +1 -0
- package/tests/mocks/preprocess/input/includes/presets.yaml +2 -0
- package/tests/mocks/preprocess/input/includes/sub/level2.md +7 -0
- package/tests/mocks/preprocess/input/includes/sub/user.md +1 -0
- package/tests/mocks/preprocess/input/includes/sub/userWithIndent.md +5 -0
- package/tests/mocks/preprocess/input/includes/test.md +1 -0
- package/tests/mocks/preprocess/input/includes/user.md +1 -0
- package/tests/mocks/preprocess/input/includes.md +18 -0
- package/tests/mocks/preprocess/input/latex.md +3 -0
- package/tests/mocks/preprocess/input/level0.md +7 -0
- package/tests/mocks/preprocess/input/level1/level1.md +7 -0
- package/tests/mocks/preprocess/input/level1/level2/level2.md +6 -0
- package/tests/mocks/preprocess/input/level1/toc.yaml +5 -0
- package/tests/mocks/preprocess/input/mermaid.md +13 -0
- package/tests/mocks/preprocess/input/presets.yaml +8 -0
- package/tests/mocks/preprocess/input/sub/folder/item-1.md +7 -0
- package/tests/mocks/preprocess/input/sub/toc.yaml +5 -0
- package/tests/mocks/preprocess/input/toc-i.yaml +3 -0
- package/tests/mocks/preprocess/input/toc.yaml +24 -0
- package/tests/mocks/redirects-validation/extensions-deprecation/input/blah.md +0 -0
- package/tests/mocks/redirects-validation/extensions-deprecation/input/redirects.yaml +5 -0
- package/tests/mocks/redirects-validation/extensions-deprecation/input/toc.yaml +4 -0
- package/tests/mocks/redirects-validation/invalid-regex/input/blah.md +0 -0
- package/tests/mocks/redirects-validation/invalid-regex/input/redirects.yaml +3 -0
- package/tests/mocks/redirects-validation/invalid-regex/input/toc.yaml +4 -0
- package/tests/mocks/redirects-validation/malformed-redirect/input/blah.md +0 -0
- package/tests/mocks/redirects-validation/malformed-redirect/input/redirects.yaml +6 -0
- package/tests/mocks/redirects-validation/malformed-redirect/input/toc.yaml +4 -0
- package/tests/mocks/redirects-validation/same-path/input/blah.md +0 -0
- package/tests/mocks/redirects-validation/same-path/input/redirects.yaml +3 -0
- package/tests/mocks/redirects-validation/same-path/input/toc.yaml +4 -0
- package/tests/mocks/redirects-validation/unparseable/input/blah.md +0 -0
- package/tests/mocks/redirects-validation/unparseable/input/redirects.yaml +11 -0
- package/tests/mocks/redirects-validation/unparseable/input/toc.yaml +4 -0
- package/tests/mocks/regression/input/.yfm +2 -0
- package/tests/mocks/regression/input/1.md +29 -0
- package/tests/mocks/regression/input/_assets/1.png +0 -0
- package/tests/mocks/regression/input/_assets/2.png +0 -0
- package/tests/mocks/regression/input/_assets/3.png +0 -0
- package/tests/mocks/regression/input/_assets/4.png +0 -0
- package/tests/mocks/regression/input/_assets/5_1.png +0 -0
- package/tests/mocks/regression/input/_assets/empty.pdf +0 -0
- package/tests/mocks/regression/input/autotitle.md +58 -0
- package/tests/mocks/regression/input/commented-include.md +3 -0
- package/tests/mocks/regression/input/entry-as-include.md +3 -0
- package/tests/mocks/regression/input/generic/1.md +3 -0
- package/tests/mocks/regression/input/generic/2.md +3 -0
- package/tests/mocks/regression/input/generic/3.md +1 -0
- package/tests/mocks/regression/input/generic/Sub notes/1.md +3 -0
- package/tests/mocks/regression/input/generic/Sub notes/2.md +3 -0
- package/tests/mocks/regression/input/images.md +13 -0
- package/tests/mocks/regression/input/included-item.md +13 -0
- package/tests/mocks/regression/input/includer-of-entry.md +5 -0
- package/tests/mocks/regression/input/includes/deep.md +3 -0
- package/tests/mocks/regression/input/includes/fragments.md +41 -0
- package/tests/mocks/regression/input/includes/presets.yaml +3 -0
- package/tests/mocks/regression/input/includes/styles.md +8 -0
- package/tests/mocks/regression/input/includes/test.md +1 -0
- package/tests/mocks/regression/input/includes/tools.md +1 -0
- package/tests/mocks/regression/input/includes/user.md +1 -0
- package/tests/mocks/regression/input/includes.md +33 -0
- package/tests/mocks/regression/input/index.yaml +9 -0
- package/tests/mocks/regression/input/latex.md +3 -0
- package/tests/mocks/regression/input/merge/merge.md +5 -0
- package/tests/mocks/regression/input/merge/presets.yaml +3 -0
- package/tests/mocks/regression/input/merge/toc.yaml +6 -0
- package/tests/mocks/regression/input/merge-source/merged.md +3 -0
- package/tests/mocks/regression/input/merge-source/toc-m.yaml +4 -0
- package/tests/mocks/regression/input/mermaid.md +13 -0
- package/tests/mocks/regression/input/openapi-spec.yaml +111 -0
- package/tests/mocks/regression/input/presets.yaml +12 -0
- package/tests/mocks/regression/input/redirects.yaml +6 -0
- package/tests/mocks/regression/input/sub/folder/item-1.md +5 -0
- package/tests/mocks/regression/input/sub/toc.yaml +5 -0
- package/tests/mocks/regression/input/toc-i.yaml +3 -0
- package/tests/mocks/regression/input/toc.yaml +43 -0
- package/tests/mocks/restricted-access/test1/input/index.md +0 -0
- package/tests/mocks/restricted-access/test1/input/plugins/index.md +0 -0
- package/tests/mocks/restricted-access/test1/input/plugins/index2.md +0 -0
- package/tests/mocks/restricted-access/test1/input/plugins/index3.md +0 -0
- package/tests/mocks/restricted-access/test1/input/plugins/index4.md +4 -0
- package/tests/mocks/restricted-access/test1/input/toc.yaml +28 -0
- package/tests/mocks/restricted-access/test2/input/index.md +0 -0
- package/tests/mocks/restricted-access/test2/input/plugins/index.md +0 -0
- package/tests/mocks/restricted-access/test2/input/project/index.md +0 -0
- package/tests/mocks/restricted-access/test2/input/toc.yaml +21 -0
- package/tests/mocks/restricted-access/test3/input/a1.md +1 -0
- package/tests/mocks/restricted-access/test3/input/folder1/a1.md +1 -0
- package/tests/mocks/restricted-access/test3/input/folder1/folder2/a1.md +1 -0
- package/tests/mocks/restricted-access/test3/input/folder1/folder2/toc.yaml +8 -0
- package/tests/mocks/restricted-access/test3/input/folder1/toc.yaml +10 -0
- package/tests/mocks/restricted-access/test3/input/index.md +0 -0
- package/tests/mocks/restricted-access/test3/input/toc.yaml +16 -0
- package/tests/mocks/rtl/multidirectional-languages/input/.yfm +1 -0
- package/tests/mocks/rtl/multidirectional-languages/input/ar/index.yaml +4 -0
- package/tests/mocks/rtl/multidirectional-languages/input/ar/page.md +1 -0
- package/tests/mocks/rtl/multidirectional-languages/input/ar/toc.yaml +5 -0
- package/tests/mocks/rtl/multidirectional-languages/input/en/index.yaml +9 -0
- package/tests/mocks/rtl/multidirectional-languages/input/en/page.md +7 -0
- package/tests/mocks/rtl/multidirectional-languages/input/en/toc.yaml +5 -0
- package/tests/mocks/rtl/rtl-language/input/.yfm +1 -0
- package/tests/mocks/rtl/rtl-language/input/index.yaml +4 -0
- package/tests/mocks/rtl/rtl-language/input/page.md +1 -0
- package/tests/mocks/rtl/rtl-language/input/toc.yaml +5 -0
- package/tests/mocks/search/input/.yfm +12 -0
- package/tests/mocks/search/input/index.md +3 -0
- package/tests/mocks/search/input/toc.yaml +1 -0
- package/tests/mocks/single-page/input/ru/index.yaml +9 -0
- package/tests/mocks/single-page/input/ru/page.md +14 -0
- package/tests/mocks/single-page/input/ru/project/config.md +1 -0
- package/tests/mocks/single-page/input/ru/toc.yaml +7 -0
- package/tests/mocks/skip-html-extension/monolingual/input/.yfm +1 -0
- package/tests/mocks/skip-html-extension/monolingual/input/folder/index.md +1 -0
- package/tests/mocks/skip-html-extension/monolingual/input/index-test-html/index.md +4 -0
- package/tests/mocks/skip-html-extension/monolingual/input/index.md +6 -0
- package/tests/mocks/skip-html-extension/monolingual/input/page1.md +3 -0
- package/tests/mocks/skip-html-extension/monolingual/input/page2.md +6 -0
- package/tests/mocks/skip-html-extension/monolingual/input/toc.yaml +13 -0
- package/tests/mocks/skip-html-extension/multilingual/input/.yfm +2 -0
- package/tests/mocks/skip-html-extension/multilingual/input/en/folder/index.md +1 -0
- package/tests/mocks/skip-html-extension/multilingual/input/en/index-test-html/index.md +4 -0
- package/tests/mocks/skip-html-extension/multilingual/input/en/index.md +6 -0
- package/tests/mocks/skip-html-extension/multilingual/input/en/page1.md +3 -0
- package/tests/mocks/skip-html-extension/multilingual/input/en/page2.md +6 -0
- package/tests/mocks/skip-html-extension/multilingual/input/en/toc.yaml +13 -0
- package/tests/mocks/skip-html-extension/multilingual/input/ru/folder/index.md +1 -0
- package/tests/mocks/skip-html-extension/multilingual/input/ru/index-test-html/index.md +4 -0
- package/tests/mocks/skip-html-extension/multilingual/input/ru/index.md +5 -0
- package/tests/mocks/skip-html-extension/multilingual/input/ru/page1.md +3 -0
- package/tests/mocks/skip-html-extension/multilingual/input/ru/page2.md +6 -0
- package/tests/mocks/skip-html-extension/multilingual/input/ru/toc.yaml +12 -0
- package/tests/mocks/themer/test1/input/.yfm +3 -0
- package/tests/mocks/themer/test1/input/_assets/style/custom.css +3 -0
- package/tests/mocks/themer/test1/input/index.md +1 -0
- package/tests/mocks/themer/test1/input/theme.yaml +14 -0
- package/tests/mocks/themer/test1/input/toc.yaml +3 -0
- package/tests/mocks/themer/test2/input/index.md +1 -0
- package/tests/mocks/themer/test2/input/theme.yaml +8 -0
- package/tests/mocks/themer/test2/input/toc.yaml +3 -0
- package/tests/mocks/themer/test3/input/index.md +1 -0
- package/tests/mocks/themer/test3/input/toc.yaml +3 -0
- package/tests/mocks/themer/test4/input/index.md +1 -0
- package/tests/mocks/themer/test4/input/theme.yaml +3 -0
- package/tests/mocks/themer/test4/input/toc.yaml +3 -0
- package/tests/mocks/themer/test5/input/.yfm +1 -0
- package/tests/mocks/themer/test5/input/index.md +1 -0
- package/tests/mocks/themer/test5/input/toc.yaml +3 -0
- package/tests/mocks/themer/test6/input/.yfm +3 -0
- package/tests/mocks/themer/test6/input/index.md +11 -0
- package/tests/mocks/themer/test6/input/toc.yaml +5 -0
- package/tests/mocks/themer/test7/input/.yfm +3 -0
- package/tests/mocks/themer/test7/input/index.md +5 -0
- package/tests/mocks/themer/test7/input/theme.yaml +7 -0
- package/tests/mocks/themer/test7/input/toc.yaml +5 -0
- package/tests/mocks/themer/test8/input/.yfm +3 -0
- package/tests/mocks/themer/test8/input/index.md +5 -0
- package/tests/mocks/themer/test8/input/toc.yaml +5 -0
- package/tests/mocks/toc-label/input/.yfm +1 -0
- package/tests/mocks/toc-label/input/index.md +3 -0
- package/tests/mocks/toc-label/input/page1.md +3 -0
- package/tests/mocks/toc-label/input/toc.yaml +10 -0
- package/tests/mocks/translation/compose/input/openapi-spec.yaml.skl +41 -0
- package/tests/mocks/translation/compose/input/openapi-spec.yaml.xliff +52 -0
- package/tests/mocks/translation/compose/input/toc.yaml.skl +8 -0
- package/tests/mocks/translation/compose/input/toc.yaml.xliff +16 -0
- package/tests/mocks/translation/conditions/input/index.md +37 -0
- package/tests/mocks/translation/conditions/input/toc.yaml +5 -0
- package/tests/mocks/translation/custom-schema/custom-openapi-schema-30.yaml +1054 -0
- package/tests/mocks/translation/dir-files/input/.yfm +6 -0
- package/tests/mocks/translation/dir-files/input/ru/_includes/test.md +1 -0
- package/tests/mocks/translation/dir-files/input/ru/_no-translate/exclude.md +1 -0
- package/tests/mocks/translation/dir-files/input/ru/aboba.md +5 -0
- package/tests/mocks/translation/dir-files/input/ru/index.md +3 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/a1.md +3 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/folder1/a1.md +3 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/folder1/toc-i.yaml +3 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/index-yfm.md +2 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/index.yaml +24 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/not-in-toc.md +20 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/syntax/base.md +3 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/syntax/index.md +2 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/syntax/lists.md +1 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/toc.yaml +19 -0
- package/tests/mocks/translation/dir-files/input/ru/nested/use_filtered_above.md +4 -0
- package/tests/mocks/translation/dir-files/input/ru/no-var-page.md +3 -0
- package/tests/mocks/translation/dir-files/input/ru/not-in-toc.md +20 -0
- package/tests/mocks/translation/dir-files/input/ru/to-be-excluded.md +1 -0
- package/tests/mocks/translation/dir-files/input/ru/toc.yaml +13 -0
- package/tests/mocks/translation/no-translate/input/index.md +7 -0
- package/tests/mocks/translation/no-translate/input/no-translate.md +57 -0
- package/tests/mocks/translation/no-translate/input/openapi-spec.yaml +37 -0
- package/tests/mocks/translation/no-translate/input/toc.yaml +11 -0
- package/tests/mocks/translation/openapi/input/openapi-spec.yaml +50 -0
- package/tests/mocks/translation/openapi/input/toc.yaml +8 -0
- package/tests/mocks/translation/toc-include/input/included-toc/merged-included-toc-item.md +1 -0
- package/tests/mocks/translation/toc-include/input/included-toc/toc.yaml +3 -0
- package/tests/mocks/translation/toc-include/input/included-toc.md +1 -0
- package/tests/mocks/translation/toc-include/input/index.md +7 -0
- package/tests/mocks/translation/toc-include/input/merged-included-toc-item.md +1 -0
- package/tests/mocks/translation/toc-include/input/no-translate.md +57 -0
- package/tests/mocks/translation/toc-include/input/openapi-spec.yaml +37 -0
- package/tests/mocks/translation/toc-include/input/toc.yaml +14 -0
- package/tests/mocks/translation/yaml-scheme/input/ru/.yfm +1 -0
- package/tests/mocks/translation/yaml-scheme/input/ru/index-direct.yaml +133 -0
- package/tests/mocks/translation/yaml-scheme/input/ru/index.yaml +32 -0
- package/tests/mocks/translation/yaml-scheme/input/ru/toc.yaml +19 -0
- package/tests/mocks/vars-conditions/input/.yfm +1 -0
- package/tests/mocks/vars-conditions/input/index.md +3 -0
- package/tests/mocks/vars-conditions/input/page1.yaml +13 -0
- package/tests/mocks/vars-conditions/input/page2.md +24 -0
- package/tests/mocks/vars-conditions/input/page3.md +1 -0
- package/tests/mocks/vars-conditions/input/page4.md +1 -0
- package/tests/mocks/vars-conditions/input/page5.yaml +10 -0
- package/tests/mocks/vars-conditions/input/presets.yaml +9 -0
- package/tests/mocks/vars-conditions/input/toc.yaml +51 -0
- package/tests/mocks/vars-ignore/input/.yfm +1 -0
- package/tests/mocks/vars-ignore/input/data/data-test.md +4 -0
- package/tests/mocks/vars-ignore/input/data/presets.yaml +3 -0
- package/tests/mocks/vars-ignore/input/data/temp-test.md +4 -0
- package/tests/mocks/vars-ignore/input/ignored/ignored-test.md +4 -0
- package/tests/mocks/vars-ignore/input/ignored/presets.yaml +3 -0
- package/tests/mocks/vars-ignore/input/presets.yaml +3 -0
- package/tests/mocks/vars-ignore/input/test.md +6 -0
- package/tests/mocks/vars-ignore/input/toc.yaml +8 -0
- package/tests/mocks/warning/unreachable-autotitle/input/index.md +1 -0
- package/tests/mocks/warning/unreachable-autotitle/input/link.md +0 -0
- package/tests/mocks/warning/unreachable-autotitle/input/toc.yaml +4 -0
- package/tests/tsconfig.json +13 -0
- package/vitest.integration.config.ts +26 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {describe, expect, test} from 'vitest';
|
|
2
|
+
import {resolve} from 'node:path';
|
|
3
|
+
import {readFileSync} from 'node:fs';
|
|
4
|
+
|
|
5
|
+
import {TestAdapter, getTestPaths} from '../fixtures';
|
|
6
|
+
|
|
7
|
+
describe('VarsService ignore patterns', () => {
|
|
8
|
+
test('should ignore presets files based on ignore patterns', async () => {
|
|
9
|
+
const {inputPath, outputPath} = getTestPaths('mocks/vars-ignore');
|
|
10
|
+
|
|
11
|
+
// Test with ignore patterns via flags - should ignore ignored/ and data/ folders
|
|
12
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
13
|
+
md2md: true,
|
|
14
|
+
args: '--ignore ignored/ --ignore data/',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Check that variables from ignored presets are not resolved
|
|
18
|
+
const outputContent = readFileSync(resolve(outputPath, 'test.md'), 'utf8');
|
|
19
|
+
expect(outputContent).toContain('Root var: rootValue');
|
|
20
|
+
expect(outputContent).toContain('Common var: fromRoot');
|
|
21
|
+
expect(outputContent).toContain('Ignored var: {{ignoredVar}}'); // Should remain unresolved
|
|
22
|
+
expect(outputContent).toContain('Data var: {{dataVar}}'); // Should remain unresolved
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('should load all presets when no ignore patterns specified', async () => {
|
|
26
|
+
const {inputPath, outputPath} = getTestPaths('mocks/vars-ignore');
|
|
27
|
+
|
|
28
|
+
// Test without ignore patterns - should load all presets
|
|
29
|
+
await TestAdapter.testBuildPass(inputPath, outputPath + '-no-ignore', {
|
|
30
|
+
md2md: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Check that variables in subdirectories are resolved
|
|
34
|
+
const ignoredContent = readFileSync(
|
|
35
|
+
resolve(outputPath + '-no-ignore', 'ignored/ignored-test.md'),
|
|
36
|
+
'utf8',
|
|
37
|
+
);
|
|
38
|
+
expect(ignoredContent).toContain('Root var: rootValue');
|
|
39
|
+
expect(ignoredContent).toContain('Ignored var: ignoredValue');
|
|
40
|
+
|
|
41
|
+
const dataContent = readFileSync(
|
|
42
|
+
resolve(outputPath + '-no-ignore', 'data/data-test.md'),
|
|
43
|
+
'utf8',
|
|
44
|
+
);
|
|
45
|
+
expect(dataContent).toContain('Root var: rootValue');
|
|
46
|
+
expect(dataContent).toContain('Data var: dataValue');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('should handle partial ignore patterns', async () => {
|
|
50
|
+
const {inputPath, outputPath} = getTestPaths('mocks/vars-ignore');
|
|
51
|
+
|
|
52
|
+
// Test with partial ignore - should ignore only data/ folder
|
|
53
|
+
await TestAdapter.testBuildPass(inputPath, outputPath + '-partial', {
|
|
54
|
+
md2md: true,
|
|
55
|
+
args: '--ignore data/',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Check that ignored/ presets are loaded but data/ presets are not
|
|
59
|
+
const ignoredContent = readFileSync(
|
|
60
|
+
resolve(outputPath + '-partial', 'ignored/ignored-test.md'),
|
|
61
|
+
'utf8',
|
|
62
|
+
);
|
|
63
|
+
expect(ignoredContent).toContain('Root var: rootValue');
|
|
64
|
+
expect(ignoredContent).toContain('Ignored var: ignoredValue'); // Should be resolved
|
|
65
|
+
|
|
66
|
+
const dataContent = readFileSync(
|
|
67
|
+
resolve(outputPath + '-partial', 'data/data-test.md'),
|
|
68
|
+
'utf8',
|
|
69
|
+
);
|
|
70
|
+
expect(dataContent).toContain('Root var: rootValue');
|
|
71
|
+
expect(dataContent).toContain('{{dataVar}}'); // Should remain unresolved
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('should handle ignore patterns with trailing slashes normalization', async () => {
|
|
75
|
+
const {inputPath, outputPath} = getTestPaths('mocks/vars-ignore');
|
|
76
|
+
|
|
77
|
+
// Test with various trailing slash patterns
|
|
78
|
+
await TestAdapter.testBuildPass(inputPath, outputPath + '-slashes', {
|
|
79
|
+
md2md: true,
|
|
80
|
+
args: '--ignore ignored// --ignore data/',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Check that both folders are ignored despite different slash patterns
|
|
84
|
+
const outputContent = readFileSync(resolve(outputPath + '-slashes', 'test.md'), 'utf8');
|
|
85
|
+
expect(outputContent).toContain('Root var: rootValue');
|
|
86
|
+
expect(outputContent).toContain('Common var: fromRoot');
|
|
87
|
+
expect(outputContent).toContain('Ignored var: {{ignoredVar}}'); // Should remain unresolved
|
|
88
|
+
expect(outputContent).toContain('Data var: {{dataVar}}'); // Should remain unresolved
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('should ignore top-level presets when using custom config for nested docs', async () => {
|
|
92
|
+
const {inputPath, outputPath} = getTestPaths('mocks/nested-docs');
|
|
93
|
+
|
|
94
|
+
// Test nested docs scenario - use custom config that ignores everything except subdoc/
|
|
95
|
+
await TestAdapter.testBuildPass(inputPath, outputPath + '-nested', {
|
|
96
|
+
md2md: true,
|
|
97
|
+
args: '--config .yfm-subdoc',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Check that subdoc files are processed and variables are resolved correctly
|
|
101
|
+
const subDocContent = readFileSync(
|
|
102
|
+
resolve(outputPath + '-nested', 'subdoc/index.md'),
|
|
103
|
+
'utf8',
|
|
104
|
+
);
|
|
105
|
+
expect(subDocContent).toContain('Sub var: subValue'); // Should be resolved from subdoc presets
|
|
106
|
+
expect(subDocContent).toContain('Common var: fromSub'); // Should use subdoc override
|
|
107
|
+
expect(subDocContent).toContain('{{topLevelVar}}'); // Should remain unresolved (top-level presets ignored)
|
|
108
|
+
|
|
109
|
+
// Verify that top-level presets.yaml was ignored by checking that top-level variables are not available
|
|
110
|
+
expect(subDocContent).not.toContain('topLevelValue');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('should not load any presets when using custom config with disabled template vars', async () => {
|
|
114
|
+
const {inputPath, outputPath} = getTestPaths('mocks/nested-docs');
|
|
115
|
+
|
|
116
|
+
// Test with custom config and --no-template-vars - should not load any presets at all
|
|
117
|
+
await TestAdapter.testBuildPass(inputPath, outputPath + '-no-vars-config', {
|
|
118
|
+
md2md: true,
|
|
119
|
+
args: '--config .yfm-subdoc --no-template-vars',
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Check that ALL variables remain unresolved (no presets loaded at all)
|
|
123
|
+
const subDocContent = readFileSync(
|
|
124
|
+
resolve(outputPath + '-no-vars-config', 'subdoc/index.md'),
|
|
125
|
+
'utf8',
|
|
126
|
+
);
|
|
127
|
+
expect(subDocContent).toContain('{{subVar}}'); // Should remain unresolved
|
|
128
|
+
expect(subDocContent).toContain('{{commonVar}}'); // Should remain unresolved
|
|
129
|
+
expect(subDocContent).toContain('{{topLevelVar}}'); // Should remain unresolved
|
|
130
|
+
|
|
131
|
+
// Verify that no variables were resolved at all
|
|
132
|
+
expect(subDocContent).not.toContain('Sub var: subValue');
|
|
133
|
+
expect(subDocContent).not.toContain('Common var: fromSub');
|
|
134
|
+
expect(subDocContent).not.toContain('Top level var: topLevelValue');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('should not load any presets when template vars are disabled', async () => {
|
|
138
|
+
const {inputPath, outputPath} = getTestPaths('mocks/vars-ignore');
|
|
139
|
+
|
|
140
|
+
// Test with --no-template-vars flag - should not load any presets
|
|
141
|
+
await TestAdapter.testBuildPass(inputPath, outputPath + '-no-vars', {
|
|
142
|
+
md2md: true,
|
|
143
|
+
args: '--no-template-vars',
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Check that ALL variables remain unresolved (no presets loaded)
|
|
147
|
+
const outputContent = readFileSync(resolve(outputPath + '-no-vars', 'test.md'), 'utf8');
|
|
148
|
+
expect(outputContent).toContain('{{rootVar}}'); // Should remain unresolved
|
|
149
|
+
expect(outputContent).toContain('{{commonVar}}'); // Should remain unresolved
|
|
150
|
+
expect(outputContent).toContain('{{ignoredVar}}'); // Should remain unresolved
|
|
151
|
+
expect(outputContent).toContain('{{dataVar}}'); // Should remain unresolved
|
|
152
|
+
|
|
153
|
+
// Check subdirectory files - variables should also remain unresolved
|
|
154
|
+
const ignoredContent = readFileSync(
|
|
155
|
+
resolve(outputPath + '-no-vars', 'ignored/ignored-test.md'),
|
|
156
|
+
'utf8',
|
|
157
|
+
);
|
|
158
|
+
expect(ignoredContent).toContain('{{rootVar}}'); // Should remain unresolved
|
|
159
|
+
expect(ignoredContent).toContain('{{ignoredVar}}'); // Should remain unresolved
|
|
160
|
+
|
|
161
|
+
const dataContent = readFileSync(
|
|
162
|
+
resolve(outputPath + '-no-vars', 'data/data-test.md'),
|
|
163
|
+
'utf8',
|
|
164
|
+
);
|
|
165
|
+
expect(dataContent).toContain('{{rootVar}}'); // Should remain unresolved
|
|
166
|
+
expect(dataContent).toContain('{{dataVar}}'); // Should remain unresolved
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import runner from './runner';
|
|
2
|
+
import {cleanupDirectory} from './file';
|
|
3
|
+
|
|
4
|
+
export interface BuildRunArgs {
|
|
5
|
+
md2md?: boolean;
|
|
6
|
+
md2html?: boolean;
|
|
7
|
+
args?: string;
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TranslateRunArgs {
|
|
12
|
+
subcommand: 'extract' | 'compose';
|
|
13
|
+
source: string;
|
|
14
|
+
target: string;
|
|
15
|
+
additionalArgs?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class Build {
|
|
19
|
+
run(input: string, output: string, args: string[], env?: Record<string, string>) {
|
|
20
|
+
return runner.runYfmDocs(
|
|
21
|
+
['--input', input, '--output', output, '--quiet', '--allowHtml', ...args],
|
|
22
|
+
env,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class Extract {
|
|
28
|
+
run(input: string, output: string, args: string[], env?: Record<string, string>) {
|
|
29
|
+
return runner.runYfmDocs(
|
|
30
|
+
['translate', 'extract', '--input', input, '--output', output, '--quiet', ...args],
|
|
31
|
+
env,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class CliTestAdapter {
|
|
37
|
+
readonly runner = runner;
|
|
38
|
+
|
|
39
|
+
readonly build = new Build();
|
|
40
|
+
|
|
41
|
+
readonly extract = new Extract();
|
|
42
|
+
|
|
43
|
+
async testBuildPass(
|
|
44
|
+
inputPath: string,
|
|
45
|
+
outputPath: string,
|
|
46
|
+
{md2md = true, md2html = true, args = '', env}: BuildRunArgs = {},
|
|
47
|
+
): Promise<void> {
|
|
48
|
+
await cleanupDirectory(outputPath);
|
|
49
|
+
await cleanupDirectory(`${outputPath}-md`);
|
|
50
|
+
await cleanupDirectory(`${outputPath}-html`);
|
|
51
|
+
|
|
52
|
+
const baseArgs = args.split(' ').filter(Boolean);
|
|
53
|
+
|
|
54
|
+
const tasks = [];
|
|
55
|
+
|
|
56
|
+
if (md2md && md2html) {
|
|
57
|
+
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md'], env));
|
|
58
|
+
tasks.push(() =>
|
|
59
|
+
this.build.run(inputPath, `${outputPath}-html`, [...baseArgs, '-f', 'html'], env),
|
|
60
|
+
);
|
|
61
|
+
} else if (md2md) {
|
|
62
|
+
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md'], env));
|
|
63
|
+
} else {
|
|
64
|
+
tasks.push(() =>
|
|
65
|
+
this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'html'], env),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
for (const task of tasks) {
|
|
70
|
+
const report = await task();
|
|
71
|
+
if (report.code > 0) {
|
|
72
|
+
throw report;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async testTranslatePass(
|
|
78
|
+
inputPath: string,
|
|
79
|
+
outputPath: string,
|
|
80
|
+
{subcommand, source, target, additionalArgs = ''}: TranslateRunArgs,
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
await cleanupDirectory(outputPath);
|
|
83
|
+
|
|
84
|
+
const baseArgs = [
|
|
85
|
+
'translate',
|
|
86
|
+
subcommand,
|
|
87
|
+
'--quiet',
|
|
88
|
+
'--input',
|
|
89
|
+
inputPath,
|
|
90
|
+
'--output',
|
|
91
|
+
outputPath,
|
|
92
|
+
'--source',
|
|
93
|
+
source,
|
|
94
|
+
'--target',
|
|
95
|
+
target,
|
|
96
|
+
...additionalArgs.split(' ').filter(Boolean),
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
await runner.runYfmDocs(baseArgs);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const TestAdapter = new CliTestAdapter();
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type {BuildRunArgs} from './cli';
|
|
2
|
+
|
|
3
|
+
import {readFileSync} from 'node:fs';
|
|
4
|
+
import {rm} from 'node:fs/promises';
|
|
5
|
+
import {join, resolve} from 'node:path';
|
|
6
|
+
import {glob} from 'glob';
|
|
7
|
+
import {expect, test} from 'vitest';
|
|
8
|
+
|
|
9
|
+
import {TestAdapter} from './cli';
|
|
10
|
+
import {bundleless, hashless, platformless} from './test';
|
|
11
|
+
|
|
12
|
+
const SYSTEM_DIRS = ['_bundle/', '_search/'];
|
|
13
|
+
|
|
14
|
+
// CLI-emitted build artifacts that aren't part of user content. Build-stats
|
|
15
|
+
// and build-content default to on for md2md, so every md2md fixture would
|
|
16
|
+
// otherwise need to list these in its snapshot.
|
|
17
|
+
const SYSTEM_ARTIFACTS = [
|
|
18
|
+
'yfm-build-manifest.json',
|
|
19
|
+
'yfm-build-stats.json',
|
|
20
|
+
'yfm-build-content.json',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export function getFileContent(filePath: string) {
|
|
24
|
+
return platformless(bundleless(readFileSync(filePath, 'utf8')));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const uselessFile = (file: string, dirs: string[]) => !dirs.some((part) => file.includes(part));
|
|
28
|
+
|
|
29
|
+
export function stripSystemLinks(content: string) {
|
|
30
|
+
const dirPattern = SYSTEM_DIRS.map((d) => d.replace('/', '\\/')).join('|');
|
|
31
|
+
|
|
32
|
+
content = content.replace(
|
|
33
|
+
new RegExp(`<script[^>]+src="(?:${dirPattern})[^"]*"[^>]*></script>`, 'g'),
|
|
34
|
+
'',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
content = content.replace(
|
|
38
|
+
new RegExp(`<link[^>]+href="(?:${dirPattern})[^"]*"[^>]*\\/?>`, 'g'),
|
|
39
|
+
'',
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
content = content.replace(
|
|
43
|
+
new RegExp(
|
|
44
|
+
`<meta http-equiv="last-modified" content="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z">`,
|
|
45
|
+
'g',
|
|
46
|
+
),
|
|
47
|
+
'<meta http-equiv="last-modified" content="2025-10-15T00:00:00.000Z">',
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
content = content.replace(
|
|
51
|
+
new RegExp(
|
|
52
|
+
`<meta property="article:modified_time" content="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z">`,
|
|
53
|
+
'g',
|
|
54
|
+
),
|
|
55
|
+
'<meta property="article:modified_time" content="2025-10-15T00:00:00.000Z">',
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
content = content.replace(
|
|
59
|
+
new RegExp(`"updatedAt":"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z"`, 'g'),
|
|
60
|
+
'"updatedAt":"2025-10-15T00:00:00.000Z"',
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
content = content.replace(/^[ \t]*\r?\n/gm, '');
|
|
64
|
+
|
|
65
|
+
return content;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function compareDirectories(
|
|
69
|
+
outputPath: string,
|
|
70
|
+
ignoreFileContent = false,
|
|
71
|
+
checkBundle = false,
|
|
72
|
+
ignoreFileList = false,
|
|
73
|
+
) {
|
|
74
|
+
const filesFromOutput = (
|
|
75
|
+
await glob(`**/*`, {
|
|
76
|
+
cwd: outputPath,
|
|
77
|
+
dot: true,
|
|
78
|
+
follow: true,
|
|
79
|
+
nodir: true,
|
|
80
|
+
posix: true,
|
|
81
|
+
})
|
|
82
|
+
).sort();
|
|
83
|
+
|
|
84
|
+
let filesForSnapshot;
|
|
85
|
+
|
|
86
|
+
if (checkBundle) {
|
|
87
|
+
filesForSnapshot = filesFromOutput;
|
|
88
|
+
} else {
|
|
89
|
+
filesForSnapshot = filesFromOutput.filter((file) =>
|
|
90
|
+
uselessFile(file, [...SYSTEM_DIRS, ...SYSTEM_ARTIFACTS]),
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Here we sort the order of the included files after all processing
|
|
95
|
+
// This is necessary for better test stability
|
|
96
|
+
// We do not care in what order these files were received and processed
|
|
97
|
+
// We sort only the final list and put it in the snapshot.
|
|
98
|
+
// `bundleless` strips dynamic (numeric-id) client chunks → drop the now-empty
|
|
99
|
+
// entries so they don't appear in the file list snapshot.
|
|
100
|
+
filesForSnapshot = filesForSnapshot.map(bundleless).map(hashless).filter(Boolean).sort();
|
|
101
|
+
|
|
102
|
+
if (!ignoreFileList) {
|
|
103
|
+
expect(JSON.stringify(filesForSnapshot, null, 2)).toMatchSnapshot('filelist');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!ignoreFileContent) {
|
|
107
|
+
filesFromOutput
|
|
108
|
+
.filter((file) => uselessFile(file, ['_assets/', ...SYSTEM_DIRS, ...SYSTEM_ARTIFACTS]))
|
|
109
|
+
.forEach((filePath) => {
|
|
110
|
+
let content = getFileContent(resolve(outputPath, filePath));
|
|
111
|
+
|
|
112
|
+
if (!checkBundle && filePath.endsWith('.html')) {
|
|
113
|
+
content = stripSystemLinks(content);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
expect(content).toMatchSnapshot();
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
type TestPaths = {
|
|
122
|
+
inputPath: string;
|
|
123
|
+
outputPath: string;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export function getTestPaths(testRootPath: string): TestPaths {
|
|
127
|
+
return {
|
|
128
|
+
inputPath: resolve(__dirname, '../', join(testRootPath, 'input')),
|
|
129
|
+
outputPath: resolve(__dirname, '../', join(testRootPath, 'output')),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function cleanupDirectory(path: string) {
|
|
134
|
+
return rm(path, {recursive: true, force: true});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function generateMapTestTemplate(
|
|
138
|
+
testTitle: string,
|
|
139
|
+
testRootPath: string,
|
|
140
|
+
options: BuildRunArgs = {},
|
|
141
|
+
) {
|
|
142
|
+
test(testTitle, async () => {
|
|
143
|
+
const {inputPath, outputPath} = getTestPaths(testRootPath);
|
|
144
|
+
|
|
145
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, options);
|
|
146
|
+
await compareDirectories(outputPath);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {resolve} from 'node:path';
|
|
2
|
+
import {execa} from 'execa';
|
|
3
|
+
import strip from 'strip-ansi';
|
|
4
|
+
|
|
5
|
+
export type Report = {
|
|
6
|
+
code: number;
|
|
7
|
+
warns: string[];
|
|
8
|
+
errors: string[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const bin = process.env.DIPLODOC_BINARY_PATH || resolve(__dirname, '../../build/index.js');
|
|
12
|
+
|
|
13
|
+
export class Runner {
|
|
14
|
+
async runYfmDocs(argv: string[], env?: Record<string, string>) {
|
|
15
|
+
const {stderr, exitCode} = await execa(bin, argv, {
|
|
16
|
+
all: true,
|
|
17
|
+
reject: false,
|
|
18
|
+
env: {...process.env, ...env},
|
|
19
|
+
});
|
|
20
|
+
const report = {
|
|
21
|
+
code: exitCode || 0,
|
|
22
|
+
warns: fillLog(/^WARN/, stderr),
|
|
23
|
+
errors: fillLog(/^ERR/, stderr),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const restLog = fillLog(/^(?!INFO|WARN|ERR)/, stderr);
|
|
27
|
+
if (restLog.length) {
|
|
28
|
+
for (const line of restLog) {
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.log(line);
|
|
31
|
+
}
|
|
32
|
+
} else if (report.code > 0) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.error(stderr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return report;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function fillLog(filter: RegExp, source: string) {
|
|
42
|
+
return source
|
|
43
|
+
.split('\n')
|
|
44
|
+
.map((line) => strip(line).trim())
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.filter((line) => line.match(filter));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default new Runner();
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import assets from '@diplodoc/cli/manifest';
|
|
2
|
+
|
|
3
|
+
export function platformless(text: string): string {
|
|
4
|
+
let index = 1;
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
hashless(text)
|
|
8
|
+
.replace(/\r\n/g, '\n')
|
|
9
|
+
// Fix for XML equiv-text attributes in Windows - handle various patterns
|
|
10
|
+
.replace(/equiv-text="[\r\n]+ "/g, 'equiv-text=" "')
|
|
11
|
+
.replace(/equiv-text="[\r\n]+&#10;"/g, 'equiv-text="&#10;"')
|
|
12
|
+
// Also normalize any other attributes that might have line ending issues
|
|
13
|
+
.replace(/(ctype|id)="[\r\n]+(.*?)"/g, '$1="$2"')
|
|
14
|
+
.replace(/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/g, 'UUID')
|
|
15
|
+
.replace(
|
|
16
|
+
/(content"?[:=]{1}[" ]{1}Diplodoc.*? )v\d+\.\d+\.\d+(?:-[\w-]+)?/g,
|
|
17
|
+
`$1vDIPLODOC-VERSION`,
|
|
18
|
+
)
|
|
19
|
+
.replace(
|
|
20
|
+
/(aria-controls=\\":term_element\\" tabindex=\\"\d\\" id=\\")[a-zA-Z0-9]{1,10}/g,
|
|
21
|
+
`$1vTERM-ID`,
|
|
22
|
+
)
|
|
23
|
+
.replace(/(\\(?![/"'])){1,2}/g, '/')
|
|
24
|
+
.replace(
|
|
25
|
+
/id=\\"inline-code-id-[a-zA-Z0-9]{8}\\"/g,
|
|
26
|
+
() => `id="inline-code-id-${index++}"`,
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function hashless(text: string): string {
|
|
32
|
+
return text
|
|
33
|
+
.replace(/-[a-z0-9]{12,16}\./g, '-hash.')
|
|
34
|
+
.replace(/(rnd|svg)-[a-z0-9]{3,8}__/g, 'rnd-hash__')
|
|
35
|
+
.replace(/(\/|\\)[a-z0-9]{12,16}-(index|registry|resources)\./g, '/hash-$2.');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Replaces hashed bundle filenames from the client manifest with stable labels
|
|
40
|
+
* and sorts bundle references to normalize platform-dependent ordering.
|
|
41
|
+
*
|
|
42
|
+
* Examples: "app-3ff8bc0b40bc2914.js" → "app-js",
|
|
43
|
+
* "vendor-00121562c7b7d3b5.rtl.css" → "vendor-rtl-css",
|
|
44
|
+
* "976-40cbc1d2518eb8ea.js" → "chunk-js" (numeric webpack chunk ID).
|
|
45
|
+
*/
|
|
46
|
+
// Matches a dynamic client chunk reference: a numeric (webpack/rspack id) base
|
|
47
|
+
// with a content hash, e.g. `_bundle/572-d105b8fc819aff93.rtl.css`,
|
|
48
|
+
// `_bundle/189-ab12cd34ef56.js`.
|
|
49
|
+
const DYNAMIC_CHUNK = String.raw`_bundle\/\d+-[a-f0-9]{12,16}(?:\.[a-z0-9]+)*\.[a-z0-9]+`;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Removes dynamic (numeric-id) client chunks from both the file list and any
|
|
53
|
+
* references inside content.
|
|
54
|
+
*
|
|
55
|
+
* These chunks are an internal detail of the client bundler: their count,
|
|
56
|
+
* extensions and even existence change between `@diplodoc/client` releases
|
|
57
|
+
* (e.g. 5.7.11 → 5.7.13 added `572-*.css` / `572-*.rtl.css`). Asserting them
|
|
58
|
+
* makes snapshots depend on the exact client version, so a floating
|
|
59
|
+
* `npm install` (Arcadia) diverges from a locked `npm ci` (GitHub). Stripping
|
|
60
|
+
* them keeps snapshots stable across client patch releases while still
|
|
61
|
+
* asserting the named bundles (app/vendor/search/extensions).
|
|
62
|
+
*/
|
|
63
|
+
function stripDynamicChunks(text: string): string {
|
|
64
|
+
// Fast path. Besides being cheaper, this guard is essential: `bundleless` is
|
|
65
|
+
// also applied to binary asset content (fonts, images), and the punctuation
|
|
66
|
+
// cleanup below would otherwise corrupt random `,,`/`[,`/`,]` byte sequences.
|
|
67
|
+
// Binary content never contains a literal `_bundle/<id>-<hash>` reference.
|
|
68
|
+
if (!new RegExp(DYNAMIC_CHUNK).test(text)) {
|
|
69
|
+
return text;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// <script ... src="_bundle/572-hash.js"></script>
|
|
73
|
+
text = text.replace(
|
|
74
|
+
new RegExp(`<script\\b[^>]*?${DYNAMIC_CHUNK}[^>]*?>\\s*<\\/script>`, 'g'),
|
|
75
|
+
'',
|
|
76
|
+
);
|
|
77
|
+
// <link ... href="_bundle/572-hash.css" ...>
|
|
78
|
+
text = text.replace(new RegExp(`<link\\b[^>]*?${DYNAMIC_CHUNK}[^>]*?\\/?>`, 'g'), '');
|
|
79
|
+
// JSON/array string element: "_bundle/572-hash.css" (optionally escaped as \"...\").
|
|
80
|
+
text = text.replace(new RegExp(`\\\\?"${DYNAMIC_CHUNK}\\\\?",?`, 'g'), '');
|
|
81
|
+
// Any remaining bare reference (e.g. a file-list entry that is exactly the chunk).
|
|
82
|
+
text = text.replace(new RegExp(DYNAMIC_CHUNK, 'g'), '');
|
|
83
|
+
// Tidy up array punctuation left behind by removed elements.
|
|
84
|
+
return text
|
|
85
|
+
.replace(/\[\s*,/g, '[')
|
|
86
|
+
.replace(/,\s*\]/g, ']')
|
|
87
|
+
.replace(/,\s*,/g, ',');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function bundleless(text: string): string {
|
|
91
|
+
// On Windows the CLI may emit `_bundle\file` or JSON-escaped `_bundle\\/file`.
|
|
92
|
+
// Collapse any mix of backslashes and forward slashes after `_bundle` into `/`.
|
|
93
|
+
text = text.replace(/_bundle[/\\]+/g, '_bundle/');
|
|
94
|
+
|
|
95
|
+
// Drop nondeterministic dynamic chunks before mapping named bundles.
|
|
96
|
+
text = stripDynamicChunks(text);
|
|
97
|
+
|
|
98
|
+
for (const entry of Object.values(assets)) {
|
|
99
|
+
for (const files of Object.values(entry)) {
|
|
100
|
+
for (const filename of files) {
|
|
101
|
+
const match = filename.match(
|
|
102
|
+
/^([a-z0-9]+)-[a-f0-9]{12,16}((?:\.[a-z]+)*)\.([a-z]+)$/,
|
|
103
|
+
);
|
|
104
|
+
if (!match) continue;
|
|
105
|
+
|
|
106
|
+
const [, rawBase, suffixes, ext] = match;
|
|
107
|
+
// Numeric (dynamic) chunks are handled by stripDynamicChunks above.
|
|
108
|
+
if (/^\d+$/.test(rawBase)) continue;
|
|
109
|
+
|
|
110
|
+
const suffixPart = suffixes.replace(/\./g, '-').slice(1); // ".rtl" → "rtl"
|
|
111
|
+
const label = suffixPart ? `${rawBase}-${suffixPart}-${ext}` : `${rawBase}-${ext}`;
|
|
112
|
+
const escapedSuffixes = suffixes.replace(/\./g, '\\.');
|
|
113
|
+
const pattern = new RegExp(
|
|
114
|
+
`${rawBase}-[a-f0-9]{12,16}${escapedSuffixes}\\.${ext}`,
|
|
115
|
+
'g',
|
|
116
|
+
);
|
|
117
|
+
text = text.replace(pattern, label);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return sortBundleTokens(text);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Sorts contiguous runs of `_bundle/` references so snapshots stay stable
|
|
127
|
+
* regardless of manifest ordering or platform.
|
|
128
|
+
*
|
|
129
|
+
* Pass 1 (line-level): sorts groups of consecutive lines containing `_bundle/`
|
|
130
|
+
* — handles HTML `<link>` / `<script>` tags on separate lines.
|
|
131
|
+
*
|
|
132
|
+
* Pass 2 (inline): sorts groups of `_bundle/` tokens on the same line separated
|
|
133
|
+
* only by punctuation — handles JSON arrays like `"cssLink":["_bundle/b","_bundle/a"]`.
|
|
134
|
+
*/
|
|
135
|
+
function sortBundleTokens(text: string): string {
|
|
136
|
+
const bundleRe = /_bundle\/[a-z0-9][-a-z0-9]*/;
|
|
137
|
+
|
|
138
|
+
// --- Pass 1: line-level sort ---
|
|
139
|
+
const lines = text.split('\n');
|
|
140
|
+
let i = 0;
|
|
141
|
+
while (i < lines.length) {
|
|
142
|
+
if (!bundleRe.test(lines[i])) {
|
|
143
|
+
i++;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const start = i;
|
|
147
|
+
while (i < lines.length && bundleRe.test(lines[i])) {
|
|
148
|
+
i++;
|
|
149
|
+
}
|
|
150
|
+
if (i - start < 2) continue;
|
|
151
|
+
|
|
152
|
+
const slice = lines.slice(start, i);
|
|
153
|
+
const sorted = [...slice].sort((a, b) => {
|
|
154
|
+
const ka = a.match(bundleRe)?.[0] ?? '';
|
|
155
|
+
const kb = b.match(bundleRe)?.[0] ?? '';
|
|
156
|
+
if (ka < kb) {
|
|
157
|
+
return -1;
|
|
158
|
+
}
|
|
159
|
+
if (ka > kb) {
|
|
160
|
+
return 1;
|
|
161
|
+
}
|
|
162
|
+
return 0;
|
|
163
|
+
});
|
|
164
|
+
for (let j = 0; j < sorted.length; j++) {
|
|
165
|
+
lines[start + j] = sorted[j];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
text = lines.join('\n');
|
|
169
|
+
|
|
170
|
+
// --- Pass 2: inline sort (JSON arrays, etc.) ---
|
|
171
|
+
const tokenRe = /_bundle\/[a-z0-9][-a-z0-9]*/g;
|
|
172
|
+
const hits: {start: number; end: number; value: string}[] = [];
|
|
173
|
+
let m;
|
|
174
|
+
while ((m = tokenRe.exec(text)) !== null) {
|
|
175
|
+
hits.push({start: m.index, end: m.index + m[0].length, value: m[0]});
|
|
176
|
+
}
|
|
177
|
+
if (hits.length < 2) return text;
|
|
178
|
+
|
|
179
|
+
// Gap between two tokens is "glue" when it contains no alphanumeric chars
|
|
180
|
+
// (ignoring `_bundle` substrings that may appear in the gap).
|
|
181
|
+
const isGlue = (gap: string) => !/[a-zA-Z0-9]/.test(gap.replace(/_bundle/g, ''));
|
|
182
|
+
|
|
183
|
+
// Group consecutive same-line tokens into runs.
|
|
184
|
+
const runs: number[][] = [[0]];
|
|
185
|
+
for (let idx = 1; idx < hits.length; idx++) {
|
|
186
|
+
const gap = text.slice(hits[idx - 1].end, hits[idx].start);
|
|
187
|
+
if (!gap.includes('\n') && isGlue(gap)) {
|
|
188
|
+
runs[runs.length - 1].push(idx);
|
|
189
|
+
} else {
|
|
190
|
+
runs.push([idx]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Sort each run with 2+ tokens, rewriting from the end to preserve offsets.
|
|
195
|
+
for (let r = runs.length - 1; r >= 0; r--) {
|
|
196
|
+
const run = runs[r];
|
|
197
|
+
if (run.length < 2) continue;
|
|
198
|
+
|
|
199
|
+
const values = run.map((idx) => hits[idx].value);
|
|
200
|
+
const sorted = [...values].sort();
|
|
201
|
+
if (values.every((v, idx) => v === sorted[idx])) continue;
|
|
202
|
+
|
|
203
|
+
for (let k = run.length - 1; k >= 0; k--) {
|
|
204
|
+
const {start: s, end: e} = hits[run[k]];
|
|
205
|
+
text = text.slice(0, s) + sorted[k] + text.slice(e);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return text;
|
|
210
|
+
}
|