@redocly/realm-plugin-asciidoc 0.8.0-next.9 → 0.8.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 +208 -0
- package/lib/.tsbuildinfo +1 -1
- package/package.json +8 -4
- package/src/asciidoc-parser.ts +0 -1025
- package/src/get-ai-search-documents.ts +0 -194
- package/src/plugin.ts +0 -675
- package/src/search-facets.ts +0 -46
- package/src/search-resolver.ts +0 -98
- package/src/template.tsx +0 -687
- package/src/types.ts +0 -178
- package/tests/asciidoc-parser.test.ts +0 -87
- package/tsconfig.build.json +0 -12
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -17
package/src/types.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
export type AsciidocFrontmatter = {
|
|
2
|
-
title: string;
|
|
3
|
-
description?: string;
|
|
4
|
-
keywords?: string[];
|
|
5
|
-
excludeFromSearch?: boolean;
|
|
6
|
-
seo?: {
|
|
7
|
-
title?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type ContentNode =
|
|
13
|
-
| ParagraphNode
|
|
14
|
-
| HeadingNode
|
|
15
|
-
| CodeBlockNode
|
|
16
|
-
| AdmonitionNode
|
|
17
|
-
| ListNode
|
|
18
|
-
| DescriptionListNode
|
|
19
|
-
| TableNode
|
|
20
|
-
| ImageNode
|
|
21
|
-
| QuoteNode
|
|
22
|
-
| SidebarNode
|
|
23
|
-
| ExampleNode
|
|
24
|
-
| CollapsibleNode
|
|
25
|
-
| ThematicBreakNode
|
|
26
|
-
| HtmlPassthroughNode
|
|
27
|
-
| SectionNode
|
|
28
|
-
| DiagramNode;
|
|
29
|
-
|
|
30
|
-
export type ParagraphNode = {
|
|
31
|
-
type: 'paragraph';
|
|
32
|
-
contentHtml: string;
|
|
33
|
-
icons: InlineIcon[];
|
|
34
|
-
role?: string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type HeadingNode = {
|
|
38
|
-
type: 'heading';
|
|
39
|
-
level: number;
|
|
40
|
-
id: string;
|
|
41
|
-
contentHtml: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type CodeBlockCallout = {
|
|
45
|
-
line: number;
|
|
46
|
-
number: number;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type CodeBlockNode = {
|
|
50
|
-
type: 'codeBlock';
|
|
51
|
-
lang: string;
|
|
52
|
-
source: string;
|
|
53
|
-
title?: string;
|
|
54
|
-
callouts?: CodeBlockCallout[];
|
|
55
|
-
calloutDescriptions?: string[];
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type AdmonitionNode = {
|
|
59
|
-
type: 'admonition';
|
|
60
|
-
admonitionType: 'info' | 'warning' | 'success' | 'danger';
|
|
61
|
-
name: string;
|
|
62
|
-
children: ContentNode[];
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type ListNode = {
|
|
66
|
-
type: 'list';
|
|
67
|
-
ordered: boolean;
|
|
68
|
-
items: ListItemNode[];
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type ListItemNode = {
|
|
72
|
-
contentHtml: string;
|
|
73
|
-
icons: InlineIcon[];
|
|
74
|
-
children: ContentNode[];
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export type DescriptionListNode = {
|
|
78
|
-
type: 'descriptionList';
|
|
79
|
-
items: DescriptionListItemNode[];
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export type DescriptionListItemNode = {
|
|
83
|
-
termsHtml: string[];
|
|
84
|
-
descriptionHtml: string;
|
|
85
|
-
descriptionIcons: InlineIcon[];
|
|
86
|
-
children: ContentNode[];
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type TableNode = {
|
|
90
|
-
type: 'table';
|
|
91
|
-
title?: string;
|
|
92
|
-
head: TableCellNode[][];
|
|
93
|
-
body: TableCellNode[][];
|
|
94
|
-
foot: TableCellNode[][];
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export type TableCellNode = {
|
|
98
|
-
contentHtml: string;
|
|
99
|
-
colSpan?: number;
|
|
100
|
-
rowSpan?: number;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export type ImageNode = {
|
|
104
|
-
type: 'image';
|
|
105
|
-
src: string;
|
|
106
|
-
alt: string;
|
|
107
|
-
title?: string;
|
|
108
|
-
width?: string;
|
|
109
|
-
height?: string;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export type QuoteNode = {
|
|
113
|
-
type: 'quote';
|
|
114
|
-
attribution?: string;
|
|
115
|
-
citeTitle?: string;
|
|
116
|
-
children: ContentNode[];
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export type SidebarNode = {
|
|
120
|
-
type: 'sidebar';
|
|
121
|
-
title?: string;
|
|
122
|
-
children: ContentNode[];
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export type ExampleNode = {
|
|
126
|
-
type: 'example';
|
|
127
|
-
title?: string;
|
|
128
|
-
children: ContentNode[];
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export type CollapsibleNode = {
|
|
132
|
-
type: 'collapsible';
|
|
133
|
-
title?: string;
|
|
134
|
-
children: ContentNode[];
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export type ThematicBreakNode = {
|
|
138
|
-
type: 'thematicBreak';
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export type HtmlPassthroughNode = {
|
|
142
|
-
type: 'htmlPassthrough';
|
|
143
|
-
html: string;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export type SectionNode = {
|
|
147
|
-
type: 'section';
|
|
148
|
-
id: string;
|
|
149
|
-
title: string;
|
|
150
|
-
titleHtml: string;
|
|
151
|
-
titleIcons: InlineIcon[];
|
|
152
|
-
level: number;
|
|
153
|
-
children: ContentNode[];
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export type DiagramNode = {
|
|
157
|
-
type: 'diagram';
|
|
158
|
-
diagramType: 'mermaid' | 'excalidraw' | 'plantuml';
|
|
159
|
-
source: string;
|
|
160
|
-
id?: string;
|
|
161
|
-
diagramHtml?: string;
|
|
162
|
-
diagramHtmlDark?: string;
|
|
163
|
-
diagramError?: string;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export type InlineIcon = {
|
|
167
|
-
name: string;
|
|
168
|
-
style: string;
|
|
169
|
-
size?: string;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export type AsciidocSection = {
|
|
173
|
-
id: string;
|
|
174
|
-
title: string;
|
|
175
|
-
level: number;
|
|
176
|
-
textContent: string;
|
|
177
|
-
children: AsciidocSection[];
|
|
178
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { parseAsciidoc } from '../src/asciidoc-parser.js';
|
|
2
|
-
|
|
3
|
-
function textContentOf(source: string): string | undefined {
|
|
4
|
-
const result = parseAsciidoc(source, 'test.adoc', '.');
|
|
5
|
-
return result.sections[0]?.textContent;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
describe('parseAsciidoc section text extraction', () => {
|
|
9
|
-
it('extracts paragraph text', () => {
|
|
10
|
-
expect(textContentOf('== S\n\nJust a paragraph.\n')).toBe('Just a paragraph.');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('extracts verse text', () => {
|
|
14
|
-
expect(textContentOf('== S\n\n[verse]\nRoses are red\nViolets are blue\n')).toBe(
|
|
15
|
-
'Roses are red\nViolets are blue',
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('extracts literal block text', () => {
|
|
20
|
-
expect(textContentOf('== S\n\n literal text line\n')).toBe('literal text line');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('extracts listing block as a fenced code block', () => {
|
|
24
|
-
expect(textContentOf('== S\n\n[source,javascript]\n----\nconst x = 1;\n----\n')).toBe(
|
|
25
|
-
'```javascript\nconst x = 1;\n```',
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('extracts a diagram open block as a fenced code block', () => {
|
|
30
|
-
expect(textContentOf('== S\n\n[mermaid]\n--\n....\ngraph TD\n....\n--\n')).toBe(
|
|
31
|
-
'```mermaid\ngraph TD\n```',
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('extracts a generic (non-diagram) open block by falling through to its inner content', () => {
|
|
36
|
-
// Regression coverage for #25965: `context === 'open'` was checked twice in an
|
|
37
|
-
// if/else-if chain, so the diagram-only branch always won and non-diagram open
|
|
38
|
-
// blocks silently contributed no text.
|
|
39
|
-
expect(textContentOf('== S\n\n--\nSome generic open block content.\n--\n')).toBe(
|
|
40
|
-
'Some generic open block content.',
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('extracts an unordered list', () => {
|
|
45
|
-
expect(textContentOf('== S\n\n* item1\n* item2\n')).toBe('- item1\n- item2');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('extracts an ordered list', () => {
|
|
49
|
-
expect(textContentOf('== S\n\n. item1\n. item2\n')).toBe('1. item1\n2. item2');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('extracts a description list', () => {
|
|
53
|
-
expect(textContentOf('== S\n\nTerm1:: Definition1\n')).toBe('**Term1**\n: Definition1');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('extracts a table', () => {
|
|
57
|
-
expect(textContentOf('== S\n\n|===\n| A | B\n| 1 | 2\n|===\n')).toBe(
|
|
58
|
-
'| A | B |\n| --- | --- |\n| 1 | 2 |',
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('extracts an inline admonition', () => {
|
|
63
|
-
expect(textContentOf('== S\n\nNOTE: Some note text\n')).toBe('> [!NOTE]\n> Some note text');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('extracts a block admonition with nested blocks', () => {
|
|
67
|
-
expect(textContentOf('== S\n\n[NOTE]\n====\nBlock note text\n====\n')).toBe(
|
|
68
|
-
'> [!NOTE]\n> Block note text',
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('extracts a quote block', () => {
|
|
73
|
-
expect(textContentOf('== S\n\n[quote]\n____\nQuoted text\n____\n')).toBe('Quoted text');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('extracts an example block', () => {
|
|
77
|
-
expect(textContentOf('== S\n\n[example]\n====\nExample text\n====\n')).toBe('Example text');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('extracts a sidebar block', () => {
|
|
81
|
-
expect(textContentOf('== S\n\n[sidebar]\n****\nSidebar text\n****\n')).toBe('Sidebar text');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('does not leak a nested subsection into its parent section text', () => {
|
|
85
|
-
expect(textContentOf('== S\n\nParent text.\n\n=== Sub\n\nChild text.\n')).toBe('Parent text.');
|
|
86
|
-
});
|
|
87
|
-
});
|
package/tsconfig.build.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"references": [{ "path": "../theme/tsconfig.build.json" }],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"noEmit": false,
|
|
6
|
-
"outDir": "lib",
|
|
7
|
-
"rootDir": "src",
|
|
8
|
-
"tsBuildInfoFile": "lib/.tsbuildinfo"
|
|
9
|
-
},
|
|
10
|
-
"extends": "./tsconfig.json",
|
|
11
|
-
"include": ["src"]
|
|
12
|
-
}
|
package/tsconfig.json
DELETED
package/vitest.config.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
globals: true,
|
|
6
|
-
reporters: process.env.CI ? ['verbose', 'json'] : ['verbose'],
|
|
7
|
-
outputFile: {
|
|
8
|
-
json: 'report.test-timing.json',
|
|
9
|
-
},
|
|
10
|
-
environment: 'node',
|
|
11
|
-
include: ['tests/**/*.test.ts'],
|
|
12
|
-
coverage: {
|
|
13
|
-
provider: 'v8',
|
|
14
|
-
include: ['src/**'],
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|