@knpkv/confluence-to-markdown 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +58 -14
- package/dist/AdfPlaceholders.d.ts +42 -0
- package/dist/AdfPlaceholders.d.ts.map +1 -0
- package/dist/AdfPlaceholders.js +547 -0
- package/dist/AdfPlaceholders.js.map +1 -0
- package/dist/AdfSchemaValidator.d.ts +37 -0
- package/dist/AdfSchemaValidator.d.ts.map +1 -0
- package/dist/AdfSchemaValidator.js +37 -0
- package/dist/AdfSchemaValidator.js.map +1 -0
- package/dist/AdfWalker.d.ts +39 -0
- package/dist/AdfWalker.d.ts.map +1 -0
- package/dist/AdfWalker.js +527 -0
- package/dist/AdfWalker.js.map +1 -0
- package/dist/AtlaskitTransformers.d.ts +35 -0
- package/dist/AtlaskitTransformers.d.ts.map +1 -0
- package/dist/AtlaskitTransformers.js +48 -0
- package/dist/AtlaskitTransformers.js.map +1 -0
- package/dist/Brand.d.ts +6 -6
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +8 -6
- package/dist/Brand.js.map +1 -1
- package/dist/ConfluenceAuth.d.ts +4 -4
- package/dist/ConfluenceAuth.d.ts.map +1 -1
- package/dist/ConfluenceAuth.js +15 -27
- package/dist/ConfluenceAuth.js.map +1 -1
- package/dist/ConfluenceClient.d.ts +4 -4
- package/dist/ConfluenceClient.d.ts.map +1 -1
- package/dist/ConfluenceClient.js +21 -14
- package/dist/ConfluenceClient.js.map +1 -1
- package/dist/ConfluenceConfig.d.ts +3 -3
- package/dist/ConfluenceConfig.d.ts.map +1 -1
- package/dist/ConfluenceConfig.js +13 -11
- package/dist/ConfluenceConfig.js.map +1 -1
- package/dist/ConfluenceError.d.ts +56 -4
- package/dist/ConfluenceError.d.ts.map +1 -1
- package/dist/ConfluenceError.js +30 -1
- package/dist/ConfluenceError.js.map +1 -1
- package/dist/GitService.d.ts +11 -3
- package/dist/GitService.d.ts.map +1 -1
- package/dist/GitService.js +19 -27
- package/dist/GitService.js.map +1 -1
- package/dist/LocalFileSystem.d.ts +3 -3
- package/dist/LocalFileSystem.d.ts.map +1 -1
- package/dist/LocalFileSystem.js +6 -6
- package/dist/LocalFileSystem.js.map +1 -1
- package/dist/MarkdownConverter.d.ts +16 -65
- package/dist/MarkdownConverter.d.ts.map +1 -1
- package/dist/MarkdownConverter.js +64 -85
- package/dist/MarkdownConverter.js.map +1 -1
- package/dist/Schemas.d.ts +128 -141
- package/dist/Schemas.d.ts.map +1 -1
- package/dist/Schemas.js +21 -23
- package/dist/Schemas.js.map +1 -1
- package/dist/SyncEngine.d.ts +8 -5
- package/dist/SyncEngine.d.ts.map +1 -1
- package/dist/SyncEngine.js +189 -113
- package/dist/SyncEngine.js.map +1 -1
- package/dist/bin.js +23 -35
- package/dist/bin.js.map +1 -1
- package/dist/commands/auth.d.ts +2 -14
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +11 -16
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/clone.d.ts +4 -6
- package/dist/commands/clone.d.ts.map +1 -1
- package/dist/commands/clone.js +34 -32
- package/dist/commands/clone.js.map +1 -1
- package/dist/commands/delete.d.ts +2 -10
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +5 -4
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/errorHandler.d.ts +2 -1
- package/dist/commands/errorHandler.d.ts.map +1 -1
- package/dist/commands/errorHandler.js +22 -15
- package/dist/commands/errorHandler.js.map +1 -1
- package/dist/commands/fetch.d.ts +27 -0
- package/dist/commands/fetch.d.ts.map +1 -0
- package/dist/commands/fetch.js +48 -0
- package/dist/commands/fetch.js.map +1 -0
- package/dist/commands/git.d.ts +7 -10
- package/dist/commands/git.d.ts.map +1 -1
- package/dist/commands/git.js +6 -6
- package/dist/commands/git.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/layers.d.ts +10 -9
- package/dist/commands/layers.d.ts.map +1 -1
- package/dist/commands/layers.js +41 -30
- package/dist/commands/layers.js.map +1 -1
- package/dist/commands/new.d.ts +2 -6
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +5 -4
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/pageInput.d.ts +19 -0
- package/dist/commands/pageInput.d.ts.map +1 -0
- package/dist/commands/pageInput.js +68 -0
- package/dist/commands/pageInput.js.map +1 -0
- package/dist/commands/root.d.ts +8 -0
- package/dist/commands/root.d.ts.map +1 -0
- package/dist/commands/root.js +29 -0
- package/dist/commands/root.js.map +1 -0
- package/dist/commands/sync.d.ts +6 -9
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +5 -6
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.d.ts +3 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -13
- package/dist/index.js.map +1 -1
- package/dist/internal/NodeLayers.d.ts.map +1 -1
- package/dist/internal/NodeLayers.js +1 -2
- package/dist/internal/NodeLayers.js.map +1 -1
- package/dist/internal/adfMetadata.d.ts +30 -0
- package/dist/internal/adfMetadata.d.ts.map +1 -0
- package/dist/internal/adfMetadata.js +126 -0
- package/dist/internal/adfMetadata.js.map +1 -0
- package/dist/internal/cleanMarkdown.d.ts +5 -0
- package/dist/internal/cleanMarkdown.d.ts.map +1 -0
- package/dist/internal/cleanMarkdown.js +13 -0
- package/dist/internal/cleanMarkdown.js.map +1 -0
- package/dist/internal/frontmatter.d.ts.map +1 -1
- package/dist/internal/frontmatter.js +41 -8
- package/dist/internal/frontmatter.js.map +1 -1
- package/dist/internal/gitCommands.d.ts +9 -3
- package/dist/internal/gitCommands.d.ts.map +1 -1
- package/dist/internal/gitCommands.js +18 -9
- package/dist/internal/gitCommands.js.map +1 -1
- package/dist/internal/hashUtils.d.ts +1 -1
- package/dist/internal/hashUtils.d.ts.map +1 -1
- package/dist/internal/hashUtils.js +1 -1
- package/dist/internal/hashUtils.js.map +1 -1
- package/dist/internal/oauthServer.d.ts +10 -5
- package/dist/internal/oauthServer.d.ts.map +1 -1
- package/dist/internal/oauthServer.js +19 -40
- package/dist/internal/oauthServer.js.map +1 -1
- package/dist/internal/pathUtils.d.ts +1 -1
- package/dist/internal/pathUtils.d.ts.map +1 -1
- package/dist/internal/pathUtils.js +1 -1
- package/dist/internal/pathUtils.js.map +1 -1
- package/dist/internal/process.d.ts +15 -0
- package/dist/internal/process.d.ts.map +1 -0
- package/dist/internal/process.js +10 -0
- package/dist/internal/process.js.map +1 -0
- package/dist/internal/stdio.d.ts +6 -0
- package/dist/internal/stdio.d.ts.map +1 -0
- package/dist/internal/stdio.js +15 -0
- package/dist/internal/stdio.js.map +1 -0
- package/dist/internal/tokenStorage.d.ts +3 -13
- package/dist/internal/tokenStorage.d.ts.map +1 -1
- package/dist/internal/tokenStorage.js +26 -24
- package/dist/internal/tokenStorage.js.map +1 -1
- package/dist/internal/userCache.d.ts +1 -1
- package/dist/internal/userCache.d.ts.map +1 -1
- package/dist/internal/userCache.js +1 -1
- package/dist/internal/userCache.js.map +1 -1
- package/package.json +29 -20
- package/skills/confluence/SKILL.md +143 -0
- package/skills/confluence/agents/openai.yaml +4 -0
- package/src/AdfPlaceholders.ts +563 -0
- package/src/AdfSchemaValidator.ts +65 -0
- package/src/AdfWalker.ts +591 -0
- package/src/AtlaskitTransformers.ts +70 -0
- package/src/Brand.ts +11 -16
- package/src/ConfluenceAuth.ts +22 -30
- package/src/ConfluenceClient.ts +28 -24
- package/src/ConfluenceConfig.ts +14 -14
- package/src/ConfluenceError.ts +65 -3
- package/src/GitService.ts +39 -49
- package/src/LocalFileSystem.ts +7 -9
- package/src/MarkdownConverter.ts +108 -143
- package/src/Schemas.ts +17 -16
- package/src/SyncEngine.ts +272 -127
- package/src/atlaskit-adf-schema.d.ts +3 -0
- package/src/bin.ts +30 -56
- package/src/commands/auth.ts +21 -18
- package/src/commands/clone.ts +46 -38
- package/src/commands/delete.ts +5 -4
- package/src/commands/errorHandler.ts +25 -18
- package/src/commands/fetch.ts +90 -0
- package/src/commands/git.ts +6 -6
- package/src/commands/index.ts +1 -0
- package/src/commands/layers.ts +64 -37
- package/src/commands/new.ts +5 -4
- package/src/commands/pageInput.ts +103 -0
- package/src/commands/root.ts +59 -0
- package/src/commands/sync.ts +7 -6
- package/src/index.ts +3 -18
- package/src/internal/NodeLayers.ts +1 -2
- package/src/internal/adfMetadata.ts +145 -0
- package/src/internal/cleanMarkdown.ts +15 -0
- package/src/internal/frontmatter.ts +45 -8
- package/src/internal/gitCommands.ts +23 -17
- package/src/internal/hashUtils.ts +2 -2
- package/src/internal/oauthServer.ts +84 -105
- package/src/internal/pathUtils.ts +1 -1
- package/src/internal/process.ts +15 -0
- package/src/internal/stdio.ts +22 -0
- package/src/internal/tokenStorage.ts +39 -29
- package/src/internal/userCache.ts +2 -2
- package/test/AdfPlaceholders.test.ts +508 -0
- package/test/AdfSchemaValidator.test.ts +34 -0
- package/test/AdfWalker.test.ts +676 -0
- package/test/AtlaskitTransformers.test.ts +25 -0
- package/test/Brand.test.ts +11 -11
- package/test/GitService.test.ts +6 -2
- package/test/MarkdownConverter.test.ts +121 -105
- package/test/RoundTrip.test.ts +521 -0
- package/test/Schemas.test.ts +40 -40
- package/test/adfMetadata.test.ts +110 -0
- package/test/cleanMarkdown.test.ts +36 -0
- package/test/commandHarness.test.ts +79 -0
- package/test/commandHarness.ts +147 -0
- package/test/fetch.test.ts +61 -0
- package/test/frontmatter.test.ts +41 -0
- package/test/integration.test.ts +569 -156
- package/test/layers.test.ts +12 -0
- package/test/oauthServer.test.ts +4 -5
- package/test/pageInput.test.ts +83 -0
- package/test/tokenStorage.test.ts +17 -17
- package/dist/SchemaConverterError.d.ts +0 -108
- package/dist/SchemaConverterError.d.ts.map +0 -1
- package/dist/SchemaConverterError.js +0 -84
- package/dist/SchemaConverterError.js.map +0 -1
- package/dist/ast/BlockNode.d.ts +0 -453
- package/dist/ast/BlockNode.d.ts.map +0 -1
- package/dist/ast/BlockNode.js +0 -310
- package/dist/ast/BlockNode.js.map +0 -1
- package/dist/ast/Document.d.ts +0 -216
- package/dist/ast/Document.d.ts.map +0 -1
- package/dist/ast/Document.js +0 -69
- package/dist/ast/Document.js.map +0 -1
- package/dist/ast/InlineNode.d.ts +0 -477
- package/dist/ast/InlineNode.d.ts.map +0 -1
- package/dist/ast/InlineNode.js +0 -263
- package/dist/ast/InlineNode.js.map +0 -1
- package/dist/ast/MacroNode.d.ts +0 -267
- package/dist/ast/MacroNode.d.ts.map +0 -1
- package/dist/ast/MacroNode.js +0 -164
- package/dist/ast/MacroNode.js.map +0 -1
- package/dist/ast/index.d.ts +0 -10
- package/dist/ast/index.d.ts.map +0 -1
- package/dist/ast/index.js +0 -14
- package/dist/ast/index.js.map +0 -1
- package/dist/parsers/ConfluenceParser.d.ts +0 -26
- package/dist/parsers/ConfluenceParser.d.ts.map +0 -1
- package/dist/parsers/ConfluenceParser.js +0 -797
- package/dist/parsers/ConfluenceParser.js.map +0 -1
- package/dist/parsers/MarkdownParser.d.ts +0 -26
- package/dist/parsers/MarkdownParser.d.ts.map +0 -1
- package/dist/parsers/MarkdownParser.js +0 -982
- package/dist/parsers/MarkdownParser.js.map +0 -1
- package/dist/parsers/index.d.ts +0 -8
- package/dist/parsers/index.d.ts.map +0 -1
- package/dist/parsers/index.js +0 -8
- package/dist/parsers/index.js.map +0 -1
- package/dist/schemas/ConfluenceSchema.d.ts +0 -21
- package/dist/schemas/ConfluenceSchema.d.ts.map +0 -1
- package/dist/schemas/ConfluenceSchema.js +0 -38
- package/dist/schemas/ConfluenceSchema.js.map +0 -1
- package/dist/schemas/ConversionSchema.d.ts +0 -35
- package/dist/schemas/ConversionSchema.d.ts.map +0 -1
- package/dist/schemas/ConversionSchema.js +0 -208
- package/dist/schemas/ConversionSchema.js.map +0 -1
- package/dist/schemas/MarkdownSchema.d.ts +0 -21
- package/dist/schemas/MarkdownSchema.d.ts.map +0 -1
- package/dist/schemas/MarkdownSchema.js +0 -38
- package/dist/schemas/MarkdownSchema.js.map +0 -1
- package/dist/schemas/hast/HastFromHtml.d.ts +0 -27
- package/dist/schemas/hast/HastFromHtml.d.ts.map +0 -1
- package/dist/schemas/hast/HastFromHtml.js +0 -107
- package/dist/schemas/hast/HastFromHtml.js.map +0 -1
- package/dist/schemas/hast/HastSchema.d.ts +0 -195
- package/dist/schemas/hast/HastSchema.d.ts.map +0 -1
- package/dist/schemas/hast/HastSchema.js +0 -183
- package/dist/schemas/hast/HastSchema.js.map +0 -1
- package/dist/schemas/hast/index.d.ts +0 -9
- package/dist/schemas/hast/index.d.ts.map +0 -1
- package/dist/schemas/hast/index.js +0 -3
- package/dist/schemas/hast/index.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -14
- package/dist/schemas/index.d.ts.map +0 -1
- package/dist/schemas/index.js +0 -16
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/mdast/MdastFromMarkdown.d.ts +0 -30
- package/dist/schemas/mdast/MdastFromMarkdown.d.ts.map +0 -1
- package/dist/schemas/mdast/MdastFromMarkdown.js +0 -79
- package/dist/schemas/mdast/MdastFromMarkdown.js.map +0 -1
- package/dist/schemas/mdast/MdastSchema.d.ts +0 -385
- package/dist/schemas/mdast/MdastSchema.d.ts.map +0 -1
- package/dist/schemas/mdast/MdastSchema.js +0 -266
- package/dist/schemas/mdast/MdastSchema.js.map +0 -1
- package/dist/schemas/mdast/index.d.ts +0 -10
- package/dist/schemas/mdast/index.d.ts.map +0 -1
- package/dist/schemas/mdast/index.js +0 -4
- package/dist/schemas/mdast/index.js.map +0 -1
- package/dist/schemas/mdast/mdastToString.d.ts +0 -13
- package/dist/schemas/mdast/mdastToString.d.ts.map +0 -1
- package/dist/schemas/mdast/mdastToString.js +0 -85
- package/dist/schemas/mdast/mdastToString.js.map +0 -1
- package/dist/schemas/nodes/block/BlockSchema.d.ts +0 -43
- package/dist/schemas/nodes/block/BlockSchema.d.ts.map +0 -1
- package/dist/schemas/nodes/block/BlockSchema.js +0 -634
- package/dist/schemas/nodes/block/BlockSchema.js.map +0 -1
- package/dist/schemas/nodes/block/index.d.ts +0 -7
- package/dist/schemas/nodes/block/index.d.ts.map +0 -1
- package/dist/schemas/nodes/block/index.js +0 -7
- package/dist/schemas/nodes/block/index.js.map +0 -1
- package/dist/schemas/nodes/index.d.ts +0 -9
- package/dist/schemas/nodes/index.d.ts.map +0 -1
- package/dist/schemas/nodes/index.js +0 -12
- package/dist/schemas/nodes/index.js.map +0 -1
- package/dist/schemas/nodes/inline/InlineSchema.d.ts +0 -48
- package/dist/schemas/nodes/inline/InlineSchema.d.ts.map +0 -1
- package/dist/schemas/nodes/inline/InlineSchema.js +0 -436
- package/dist/schemas/nodes/inline/InlineSchema.js.map +0 -1
- package/dist/schemas/nodes/inline/index.d.ts +0 -7
- package/dist/schemas/nodes/inline/index.d.ts.map +0 -1
- package/dist/schemas/nodes/inline/index.js +0 -7
- package/dist/schemas/nodes/inline/index.js.map +0 -1
- package/dist/schemas/nodes/macro/MacroSchema.d.ts +0 -27
- package/dist/schemas/nodes/macro/MacroSchema.d.ts.map +0 -1
- package/dist/schemas/nodes/macro/MacroSchema.js +0 -162
- package/dist/schemas/nodes/macro/MacroSchema.js.map +0 -1
- package/dist/schemas/nodes/macro/index.d.ts +0 -7
- package/dist/schemas/nodes/macro/index.d.ts.map +0 -1
- package/dist/schemas/nodes/macro/index.js +0 -7
- package/dist/schemas/nodes/macro/index.js.map +0 -1
- package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts +0 -24
- package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts.map +0 -1
- package/dist/schemas/preprocessing/ConfluencePreprocessor.js +0 -359
- package/dist/schemas/preprocessing/ConfluencePreprocessor.js.map +0 -1
- package/dist/schemas/preprocessing/index.d.ts +0 -8
- package/dist/schemas/preprocessing/index.d.ts.map +0 -1
- package/dist/schemas/preprocessing/index.js +0 -2
- package/dist/schemas/preprocessing/index.js.map +0 -1
- package/dist/serializers/ConfluenceSerializer.d.ts +0 -30
- package/dist/serializers/ConfluenceSerializer.d.ts.map +0 -1
- package/dist/serializers/ConfluenceSerializer.js +0 -560
- package/dist/serializers/ConfluenceSerializer.js.map +0 -1
- package/dist/serializers/MarkdownSerializer.d.ts +0 -34
- package/dist/serializers/MarkdownSerializer.d.ts.map +0 -1
- package/dist/serializers/MarkdownSerializer.js +0 -395
- package/dist/serializers/MarkdownSerializer.js.map +0 -1
- package/dist/serializers/index.d.ts +0 -8
- package/dist/serializers/index.d.ts.map +0 -1
- package/dist/serializers/index.js +0 -8
- package/dist/serializers/index.js.map +0 -1
- package/src/SchemaConverterError.ts +0 -108
- package/src/ast/BlockNode.ts +0 -469
- package/src/ast/Document.ts +0 -90
- package/src/ast/InlineNode.ts +0 -323
- package/src/ast/MacroNode.ts +0 -245
- package/src/ast/index.ts +0 -83
- package/src/parsers/ConfluenceParser.ts +0 -956
- package/src/parsers/MarkdownParser.ts +0 -1338
- package/src/parsers/index.ts +0 -8
- package/src/schemas/ConfluenceSchema.ts +0 -56
- package/src/schemas/ConversionSchema.ts +0 -318
- package/src/schemas/MarkdownSchema.ts +0 -56
- package/src/schemas/hast/HastFromHtml.ts +0 -153
- package/src/schemas/hast/HastSchema.ts +0 -274
- package/src/schemas/hast/index.ts +0 -35
- package/src/schemas/index.ts +0 -20
- package/src/schemas/mdast/MdastFromMarkdown.ts +0 -118
- package/src/schemas/mdast/MdastSchema.ts +0 -566
- package/src/schemas/mdast/index.ts +0 -59
- package/src/schemas/mdast/mdastToString.ts +0 -102
- package/src/schemas/nodes/block/BlockSchema.ts +0 -773
- package/src/schemas/nodes/block/index.ts +0 -13
- package/src/schemas/nodes/index.ts +0 -20
- package/src/schemas/nodes/inline/InlineSchema.ts +0 -523
- package/src/schemas/nodes/inline/index.ts +0 -14
- package/src/schemas/nodes/macro/MacroSchema.ts +0 -226
- package/src/schemas/nodes/macro/index.ts +0 -6
- package/src/schemas/preprocessing/ConfluencePreprocessor.ts +0 -455
- package/src/schemas/preprocessing/index.ts +0 -8
- package/src/serializers/ConfluenceSerializer.ts +0 -737
- package/src/serializers/MarkdownSerializer.ts +0 -543
- package/src/serializers/index.ts +0 -8
- package/test/ast/BlockNode.test.ts +0 -265
- package/test/ast/Document.test.ts +0 -126
- package/test/ast/InlineNode.test.ts +0 -161
- package/test/fixtures/integration-test.html.fixture +0 -103
- package/test/fixtures/integration-test.md.expected +0 -257
- package/test/parsers/ConfluenceParser.test.ts +0 -452
- package/test/schemas/ConfluencePreprocessor.test.ts +0 -180
- package/test/schemas/ConversionSchema.test.ts +0 -159
- package/test/schemas/HastSchema.test.ts +0 -138
- package/test/schemas/MdastSchema.test.ts +0 -145
- package/test/schemas/nodes/block/BlockSchema.test.ts +0 -173
- package/test/schemas/nodes/inline/InlineSchema.test.ts +0 -198
- package/test/schemas/nodes/macro/MacroSchema.test.ts +0 -142
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import type { UnsupportedInline } from "../../../../src/ast/InlineNode.js"
|
|
3
|
-
import { Emphasis, InlineCode, LineBreak, Link, Strong, Text } from "../../../../src/ast/InlineNode.js"
|
|
4
|
-
import { makeHastText } from "../../../../src/schemas/hast/index.js"
|
|
5
|
-
import { makeMdastText } from "../../../../src/schemas/mdast/index.js"
|
|
6
|
-
import {
|
|
7
|
-
inlineNodeFromMdast,
|
|
8
|
-
inlineNodeToHast,
|
|
9
|
-
inlineNodeToMdast,
|
|
10
|
-
textFromHastText
|
|
11
|
-
} from "../../../../src/schemas/nodes/inline/index.js"
|
|
12
|
-
|
|
13
|
-
describe("InlineSchema", () => {
|
|
14
|
-
describe("textFromHastText", () => {
|
|
15
|
-
it("converts hast text to Text node", () => {
|
|
16
|
-
const hastText = makeHastText("hello")
|
|
17
|
-
const result = textFromHastText(hastText)
|
|
18
|
-
expect(result._tag).toBe("Text")
|
|
19
|
-
expect(result.value).toBe("hello")
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
describe("inlineNodeToHast", () => {
|
|
24
|
-
it("converts Text to hast text", () => {
|
|
25
|
-
const text = new Text({ value: "hello" })
|
|
26
|
-
const result = inlineNodeToHast(text)
|
|
27
|
-
expect(result._tag).toBe("text")
|
|
28
|
-
expect((result as { value: string }).value).toBe("hello")
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it("converts Strong to hast strong", () => {
|
|
32
|
-
const strong = new Strong({ children: [new Text({ value: "bold" })] })
|
|
33
|
-
const result = inlineNodeToHast(strong)
|
|
34
|
-
expect(result._tag).toBe("element")
|
|
35
|
-
expect((result as { tagName: string }).tagName).toBe("strong")
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it("converts Emphasis to hast em", () => {
|
|
39
|
-
const emphasis = new Emphasis({ children: [new Text({ value: "italic" })] })
|
|
40
|
-
const result = inlineNodeToHast(emphasis)
|
|
41
|
-
expect(result._tag).toBe("element")
|
|
42
|
-
expect((result as { tagName: string }).tagName).toBe("em")
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it("converts InlineCode to hast code", () => {
|
|
46
|
-
const code = new InlineCode({ value: "const x = 1" })
|
|
47
|
-
const result = inlineNodeToHast(code)
|
|
48
|
-
expect(result._tag).toBe("element")
|
|
49
|
-
expect((result as { tagName: string }).tagName).toBe("code")
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it("converts Link to hast anchor", () => {
|
|
53
|
-
const link = new Link({
|
|
54
|
-
href: "https://example.com",
|
|
55
|
-
title: "Example",
|
|
56
|
-
children: [new Text({ value: "click" })]
|
|
57
|
-
})
|
|
58
|
-
const result = inlineNodeToHast(link)
|
|
59
|
-
expect(result._tag).toBe("element")
|
|
60
|
-
expect((result as { tagName: string }).tagName).toBe("a")
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it("converts LineBreak to hast br", () => {
|
|
64
|
-
const br = new LineBreak({})
|
|
65
|
-
const result = inlineNodeToHast(br)
|
|
66
|
-
expect(result._tag).toBe("element")
|
|
67
|
-
expect((result as { tagName: string }).tagName).toBe("br")
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
describe("inlineNodeToMdast", () => {
|
|
72
|
-
it("converts Text to mdast text", () => {
|
|
73
|
-
const text = new Text({ value: "hello" })
|
|
74
|
-
const result = inlineNodeToMdast(text)
|
|
75
|
-
expect(result.type).toBe("text")
|
|
76
|
-
expect((result as { value: string }).value).toBe("hello")
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it("converts Strong to mdast strong", () => {
|
|
80
|
-
const strong = new Strong({ children: [new Text({ value: "bold" })] })
|
|
81
|
-
const result = inlineNodeToMdast(strong)
|
|
82
|
-
expect(result.type).toBe("strong")
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it("converts Emphasis to mdast emphasis", () => {
|
|
86
|
-
const emphasis = new Emphasis({ children: [new Text({ value: "italic" })] })
|
|
87
|
-
const result = inlineNodeToMdast(emphasis)
|
|
88
|
-
expect(result.type).toBe("emphasis")
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it("converts InlineCode to mdast inlineCode", () => {
|
|
92
|
-
const code = new InlineCode({ value: "x" })
|
|
93
|
-
const result = inlineNodeToMdast(code)
|
|
94
|
-
expect(result.type).toBe("inlineCode")
|
|
95
|
-
expect((result as { value: string }).value).toBe("x")
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it("converts Link to mdast link", () => {
|
|
99
|
-
const link = new Link({
|
|
100
|
-
href: "https://example.com",
|
|
101
|
-
children: [new Text({ value: "click" })]
|
|
102
|
-
})
|
|
103
|
-
const result = inlineNodeToMdast(link)
|
|
104
|
-
expect(result.type).toBe("link")
|
|
105
|
-
expect((result as { url: string }).url).toBe("https://example.com")
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it("converts LineBreak to mdast break", () => {
|
|
109
|
-
const br = new LineBreak({})
|
|
110
|
-
const result = inlineNodeToMdast(br)
|
|
111
|
-
expect(result.type).toBe("break")
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
describe("inlineNodeFromMdast", () => {
|
|
116
|
-
it("converts mdast text to Text", () => {
|
|
117
|
-
const mdast = makeMdastText("hello")
|
|
118
|
-
const result = inlineNodeFromMdast(mdast)
|
|
119
|
-
expect(result._tag).toBe("Text")
|
|
120
|
-
expect((result as Text).value).toBe("hello")
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
it("converts mdast strong to Strong", () => {
|
|
124
|
-
const mdast = { type: "strong" as const, children: [makeMdastText("bold")] }
|
|
125
|
-
const result = inlineNodeFromMdast(mdast)
|
|
126
|
-
expect(result._tag).toBe("Strong")
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
it("converts mdast emphasis to Emphasis", () => {
|
|
130
|
-
const mdast = { type: "emphasis" as const, children: [makeMdastText("italic")] }
|
|
131
|
-
const result = inlineNodeFromMdast(mdast)
|
|
132
|
-
expect(result._tag).toBe("Emphasis")
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
it("converts mdast inlineCode to InlineCode", () => {
|
|
136
|
-
const mdast = { type: "inlineCode" as const, value: "x" }
|
|
137
|
-
const result = inlineNodeFromMdast(mdast)
|
|
138
|
-
expect(result._tag).toBe("InlineCode")
|
|
139
|
-
expect((result as InlineCode).value).toBe("x")
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
it("converts mdast link to Link", () => {
|
|
143
|
-
const mdast = {
|
|
144
|
-
type: "link" as const,
|
|
145
|
-
url: "https://example.com",
|
|
146
|
-
title: null,
|
|
147
|
-
children: [makeMdastText("click")]
|
|
148
|
-
}
|
|
149
|
-
const result = inlineNodeFromMdast(mdast)
|
|
150
|
-
expect(result._tag).toBe("Link")
|
|
151
|
-
expect((result as Link).href).toBe("https://example.com")
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it("converts mdast break to LineBreak", () => {
|
|
155
|
-
const mdast = { type: "break" as const }
|
|
156
|
-
const result = inlineNodeFromMdast(mdast)
|
|
157
|
-
expect(result._tag).toBe("LineBreak")
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it("converts mdast delete to Strikethrough", () => {
|
|
161
|
-
const mdast = { type: "delete" as const, children: [makeMdastText("deleted")] }
|
|
162
|
-
const result = inlineNodeFromMdast(mdast)
|
|
163
|
-
expect(result._tag).toBe("Strikethrough")
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
it("converts mdast html to UnsupportedInline", () => {
|
|
167
|
-
const mdast = { type: "html" as const, value: "<custom>x</custom>" }
|
|
168
|
-
const result = inlineNodeFromMdast(mdast)
|
|
169
|
-
expect(result._tag).toBe("UnsupportedInline")
|
|
170
|
-
expect((result as UnsupportedInline).raw).toBe("<custom>x</custom>")
|
|
171
|
-
})
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
describe("roundtrip", () => {
|
|
175
|
-
it("Text roundtrips through MDAST", () => {
|
|
176
|
-
const original = new Text({ value: "hello" })
|
|
177
|
-
const mdast = inlineNodeToMdast(original)
|
|
178
|
-
const result = inlineNodeFromMdast(mdast)
|
|
179
|
-
expect(result._tag).toBe("Text")
|
|
180
|
-
expect((result as Text).value).toBe("hello")
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
it("Strong roundtrips through MDAST", () => {
|
|
184
|
-
const original = new Strong({ children: [new Text({ value: "bold" })] })
|
|
185
|
-
const mdast = inlineNodeToMdast(original)
|
|
186
|
-
const result = inlineNodeFromMdast(mdast)
|
|
187
|
-
expect(result._tag).toBe("Strong")
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
it("Text roundtrips through HAST", () => {
|
|
191
|
-
const original = new Text({ value: "hello" })
|
|
192
|
-
const hast = inlineNodeToHast(original)
|
|
193
|
-
const result = textFromHastText(hast as { _tag: "text"; value: string })
|
|
194
|
-
expect(result._tag).toBe("Text")
|
|
195
|
-
expect(result.value).toBe("hello")
|
|
196
|
-
})
|
|
197
|
-
})
|
|
198
|
-
})
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { Paragraph } from "../../../../src/ast/BlockNode.js"
|
|
3
|
-
import { Text } from "../../../../src/ast/InlineNode.js"
|
|
4
|
-
import type { CodeMacro, ExpandMacro, InfoPanel, StatusMacro, TocMacro } from "../../../../src/ast/MacroNode.js"
|
|
5
|
-
import { macroNodeToHast, macroNodeToMdast } from "../../../../src/schemas/nodes/macro/index.js"
|
|
6
|
-
|
|
7
|
-
describe("MacroSchema", () => {
|
|
8
|
-
describe("macroNodeToHast", () => {
|
|
9
|
-
it("converts InfoPanel to hast div with data attributes", () => {
|
|
10
|
-
const panel: InfoPanel = {
|
|
11
|
-
_tag: "InfoPanel",
|
|
12
|
-
version: 1,
|
|
13
|
-
panelType: "warning",
|
|
14
|
-
title: "Important",
|
|
15
|
-
children: [new Paragraph({ children: [new Text({ value: "Content" })] })]
|
|
16
|
-
}
|
|
17
|
-
const result = macroNodeToHast(panel)
|
|
18
|
-
expect(result._tag).toBe("element")
|
|
19
|
-
expect(result.tagName).toBe("div")
|
|
20
|
-
expect(result.properties?.dataMacro).toBe("warning")
|
|
21
|
-
expect(result.properties?.dataTitle).toBe("Important")
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it("converts ExpandMacro to hast details element", () => {
|
|
25
|
-
const expand: ExpandMacro = {
|
|
26
|
-
_tag: "ExpandMacro",
|
|
27
|
-
version: 1,
|
|
28
|
-
title: "Click to expand",
|
|
29
|
-
children: [new Paragraph({ children: [new Text({ value: "Hidden" })] })]
|
|
30
|
-
}
|
|
31
|
-
const result = macroNodeToHast(expand)
|
|
32
|
-
expect(result._tag).toBe("element")
|
|
33
|
-
expect(result.tagName).toBe("details")
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it("converts TocMacro to hast nav element", () => {
|
|
37
|
-
const toc: TocMacro = {
|
|
38
|
-
_tag: "TocMacro",
|
|
39
|
-
version: 1,
|
|
40
|
-
minLevel: 2,
|
|
41
|
-
maxLevel: 4
|
|
42
|
-
}
|
|
43
|
-
const result = macroNodeToHast(toc)
|
|
44
|
-
expect(result._tag).toBe("element")
|
|
45
|
-
expect(result.tagName).toBe("nav")
|
|
46
|
-
expect(result.properties?.dataMacro).toBe("toc")
|
|
47
|
-
expect(result.properties?.dataMin).toBe("2")
|
|
48
|
-
expect(result.properties?.dataMax).toBe("4")
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it("converts CodeMacro to hast pre/code elements", () => {
|
|
52
|
-
const code: CodeMacro = {
|
|
53
|
-
_tag: "CodeMacro",
|
|
54
|
-
version: 1,
|
|
55
|
-
language: "typescript",
|
|
56
|
-
code: "const x = 1",
|
|
57
|
-
lineNumbers: false,
|
|
58
|
-
collapse: false
|
|
59
|
-
}
|
|
60
|
-
const result = macroNodeToHast(code)
|
|
61
|
-
expect(result._tag).toBe("element")
|
|
62
|
-
expect(result.tagName).toBe("pre")
|
|
63
|
-
expect(result.properties?.dataLanguage).toBe("typescript")
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it("converts StatusMacro to hast span element", () => {
|
|
67
|
-
const status: StatusMacro = {
|
|
68
|
-
_tag: "StatusMacro",
|
|
69
|
-
version: 1,
|
|
70
|
-
text: "Done",
|
|
71
|
-
color: "Green"
|
|
72
|
-
}
|
|
73
|
-
const result = macroNodeToHast(status)
|
|
74
|
-
expect(result._tag).toBe("element")
|
|
75
|
-
expect(result.tagName).toBe("span")
|
|
76
|
-
expect(result.properties?.dataMacro).toBe("status")
|
|
77
|
-
expect(result.properties?.dataColor).toBe("Green")
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
describe("macroNodeToMdast", () => {
|
|
82
|
-
it("converts InfoPanel to mdast html with container syntax", () => {
|
|
83
|
-
const panel: InfoPanel = {
|
|
84
|
-
_tag: "InfoPanel",
|
|
85
|
-
version: 1,
|
|
86
|
-
panelType: "info",
|
|
87
|
-
children: [new Paragraph({ children: [new Text({ value: "Note content" })] })]
|
|
88
|
-
}
|
|
89
|
-
const result = macroNodeToMdast(panel)
|
|
90
|
-
expect(result.type).toBe("html")
|
|
91
|
-
expect((result as { value: string }).value).toContain(":::info")
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it("converts ExpandMacro to mdast html with details element", () => {
|
|
95
|
-
const expand: ExpandMacro = {
|
|
96
|
-
_tag: "ExpandMacro",
|
|
97
|
-
version: 1,
|
|
98
|
-
title: "More info",
|
|
99
|
-
children: []
|
|
100
|
-
}
|
|
101
|
-
const result = macroNodeToMdast(expand)
|
|
102
|
-
expect(result.type).toBe("html")
|
|
103
|
-
expect((result as { value: string }).value).toContain("<details>")
|
|
104
|
-
expect((result as { value: string }).value).toContain("More info")
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it("converts TocMacro to mdast html with toc marker", () => {
|
|
108
|
-
const toc: TocMacro = {
|
|
109
|
-
_tag: "TocMacro",
|
|
110
|
-
version: 1
|
|
111
|
-
}
|
|
112
|
-
const result = macroNodeToMdast(toc)
|
|
113
|
-
expect(result.type).toBe("html")
|
|
114
|
-
expect((result as { value: string }).value).toBe("[[toc]]")
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
it("converts CodeMacro to mdast code", () => {
|
|
118
|
-
const code: CodeMacro = {
|
|
119
|
-
_tag: "CodeMacro",
|
|
120
|
-
version: 1,
|
|
121
|
-
language: "py",
|
|
122
|
-
code: "print(1)",
|
|
123
|
-
lineNumbers: false,
|
|
124
|
-
collapse: false
|
|
125
|
-
}
|
|
126
|
-
const result = macroNodeToMdast(code)
|
|
127
|
-
expect(result.type).toBe("code")
|
|
128
|
-
expect((result as { value: string }).value).toBe("print(1)")
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
it("converts StatusMacro to mdast paragraph with badge text", () => {
|
|
132
|
-
const status: StatusMacro = {
|
|
133
|
-
_tag: "StatusMacro",
|
|
134
|
-
version: 1,
|
|
135
|
-
text: "In Progress",
|
|
136
|
-
color: "Blue"
|
|
137
|
-
}
|
|
138
|
-
const result = macroNodeToMdast(status)
|
|
139
|
-
expect(result.type).toBe("paragraph")
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
})
|