docusaurus-plugin-gitbook 0.1.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/README.md +210 -0
- package/lib/index.d.ts +51 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +39 -0
- package/lib/index.js.map +1 -0
- package/lib/parser/index.d.ts +6 -0
- package/lib/parser/index.d.ts.map +1 -0
- package/lib/parser/index.js +6 -0
- package/lib/parser/index.js.map +1 -0
- package/lib/parser/parser.d.ts +43 -0
- package/lib/parser/parser.d.ts.map +1 -0
- package/lib/parser/parser.js +192 -0
- package/lib/parser/parser.js.map +1 -0
- package/lib/parser/tokenizer.d.ts +37 -0
- package/lib/parser/tokenizer.d.ts.map +1 -0
- package/lib/parser/tokenizer.js +172 -0
- package/lib/parser/tokenizer.js.map +1 -0
- package/lib/rehype/index.d.ts +7 -0
- package/lib/rehype/index.d.ts.map +1 -0
- package/lib/rehype/index.js +6 -0
- package/lib/rehype/index.js.map +1 -0
- package/lib/rehype/plugin.d.ts +18 -0
- package/lib/rehype/plugin.d.ts.map +1 -0
- package/lib/rehype/plugin.js +31 -0
- package/lib/rehype/plugin.js.map +1 -0
- package/lib/rehype/transformers/all.d.ts +8 -0
- package/lib/rehype/transformers/all.d.ts.map +1 -0
- package/lib/rehype/transformers/all.js +10 -0
- package/lib/rehype/transformers/all.js.map +1 -0
- package/lib/rehype/transformers/button.d.ts +17 -0
- package/lib/rehype/transformers/button.d.ts.map +1 -0
- package/lib/rehype/transformers/button.js +46 -0
- package/lib/rehype/transformers/button.js.map +1 -0
- package/lib/rehype/transformers/cards.d.ts +17 -0
- package/lib/rehype/transformers/cards.d.ts.map +1 -0
- package/lib/rehype/transformers/cards.js +111 -0
- package/lib/rehype/transformers/cards.js.map +1 -0
- package/lib/rehype/transformers/expression.d.ts +17 -0
- package/lib/rehype/transformers/expression.d.ts.map +1 -0
- package/lib/rehype/transformers/expression.js +50 -0
- package/lib/rehype/transformers/expression.js.map +1 -0
- package/lib/rehype/transformers/icon.d.ts +18 -0
- package/lib/rehype/transformers/icon.d.ts.map +1 -0
- package/lib/rehype/transformers/icon.js +48 -0
- package/lib/rehype/transformers/icon.js.map +1 -0
- package/lib/rehype/transformers/index.d.ts +26 -0
- package/lib/rehype/transformers/index.d.ts.map +1 -0
- package/lib/rehype/transformers/index.js +31 -0
- package/lib/rehype/transformers/index.js.map +1 -0
- package/lib/remark/index.d.ts +8 -0
- package/lib/remark/index.d.ts.map +1 -0
- package/lib/remark/index.js +7 -0
- package/lib/remark/index.js.map +1 -0
- package/lib/remark/plugin.d.ts +22 -0
- package/lib/remark/plugin.d.ts.map +1 -0
- package/lib/remark/plugin.js +231 -0
- package/lib/remark/plugin.js.map +1 -0
- package/lib/remark/transformers/all.d.ts +14 -0
- package/lib/remark/transformers/all.d.ts.map +1 -0
- package/lib/remark/transformers/all.js +16 -0
- package/lib/remark/transformers/all.js.map +1 -0
- package/lib/remark/transformers/code.d.ts +13 -0
- package/lib/remark/transformers/code.d.ts.map +1 -0
- package/lib/remark/transformers/code.js +35 -0
- package/lib/remark/transformers/code.js.map +1 -0
- package/lib/remark/transformers/columns.d.ts +17 -0
- package/lib/remark/transformers/columns.d.ts.map +1 -0
- package/lib/remark/transformers/columns.js +41 -0
- package/lib/remark/transformers/columns.js.map +1 -0
- package/lib/remark/transformers/embed.d.ts +12 -0
- package/lib/remark/transformers/embed.d.ts.map +1 -0
- package/lib/remark/transformers/embed.js +23 -0
- package/lib/remark/transformers/embed.js.map +1 -0
- package/lib/remark/transformers/file.d.ts +13 -0
- package/lib/remark/transformers/file.d.ts.map +1 -0
- package/lib/remark/transformers/file.js +26 -0
- package/lib/remark/transformers/file.js.map +1 -0
- package/lib/remark/transformers/hint.d.ts +19 -0
- package/lib/remark/transformers/hint.d.ts.map +1 -0
- package/lib/remark/transformers/hint.js +37 -0
- package/lib/remark/transformers/hint.js.map +1 -0
- package/lib/remark/transformers/include.d.ts +16 -0
- package/lib/remark/transformers/include.d.ts.map +1 -0
- package/lib/remark/transformers/include.js +28 -0
- package/lib/remark/transformers/include.js.map +1 -0
- package/lib/remark/transformers/index.d.ts +27 -0
- package/lib/remark/transformers/index.d.ts.map +1 -0
- package/lib/remark/transformers/index.js +32 -0
- package/lib/remark/transformers/index.js.map +1 -0
- package/lib/remark/transformers/openapi.d.ts +17 -0
- package/lib/remark/transformers/openapi.d.ts.map +1 -0
- package/lib/remark/transformers/openapi.js +30 -0
- package/lib/remark/transformers/openapi.js.map +1 -0
- package/lib/remark/transformers/stepper.d.ts +17 -0
- package/lib/remark/transformers/stepper.d.ts.map +1 -0
- package/lib/remark/transformers/stepper.js +44 -0
- package/lib/remark/transformers/stepper.js.map +1 -0
- package/lib/remark/transformers/tabs.d.ts +18 -0
- package/lib/remark/transformers/tabs.d.ts.map +1 -0
- package/lib/remark/transformers/tabs.js +45 -0
- package/lib/remark/transformers/tabs.js.map +1 -0
- package/lib/remark/transformers/updates.d.ts +17 -0
- package/lib/remark/transformers/updates.d.ts.map +1 -0
- package/lib/remark/transformers/updates.js +44 -0
- package/lib/remark/transformers/updates.js.map +1 -0
- package/lib/remark/utils.d.ts +39 -0
- package/lib/remark/utils.d.ts.map +1 -0
- package/lib/remark/utils.js +139 -0
- package/lib/remark/utils.js.map +1 -0
- package/lib/theme/FAIcon/index.d.ts +10 -0
- package/lib/theme/FAIcon/index.d.ts.map +1 -0
- package/lib/theme/FAIcon/index.js +5 -0
- package/lib/theme/FAIcon/index.js.map +1 -0
- package/lib/theme/GitBookButton/index.d.ts +9 -0
- package/lib/theme/GitBookButton/index.d.ts.map +1 -0
- package/lib/theme/GitBookButton/index.js +6 -0
- package/lib/theme/GitBookButton/index.js.map +1 -0
- package/lib/theme/GitBookButton/styles.module.css +66 -0
- package/lib/theme/GitBookCard/index.d.ts +9 -0
- package/lib/theme/GitBookCard/index.d.ts.map +1 -0
- package/lib/theme/GitBookCard/index.js +6 -0
- package/lib/theme/GitBookCard/index.js.map +1 -0
- package/lib/theme/GitBookCard/styles.module.css +51 -0
- package/lib/theme/GitBookCards/index.d.ts +9 -0
- package/lib/theme/GitBookCards/index.d.ts.map +1 -0
- package/lib/theme/GitBookCards/index.js +6 -0
- package/lib/theme/GitBookCards/index.js.map +1 -0
- package/lib/theme/GitBookCards/styles.module.css +16 -0
- package/lib/theme/GitBookCodeBlock/index.d.ts +9 -0
- package/lib/theme/GitBookCodeBlock/index.d.ts.map +1 -0
- package/lib/theme/GitBookCodeBlock/index.js +6 -0
- package/lib/theme/GitBookCodeBlock/index.js.map +1 -0
- package/lib/theme/GitBookCodeBlock/styles.module.css +59 -0
- package/lib/theme/GitBookColumn/index.d.ts +9 -0
- package/lib/theme/GitBookColumn/index.d.ts.map +1 -0
- package/lib/theme/GitBookColumn/index.js +6 -0
- package/lib/theme/GitBookColumn/index.js.map +1 -0
- package/lib/theme/GitBookColumn/styles.module.css +16 -0
- package/lib/theme/GitBookColumns/index.d.ts +9 -0
- package/lib/theme/GitBookColumns/index.d.ts.map +1 -0
- package/lib/theme/GitBookColumns/index.js +6 -0
- package/lib/theme/GitBookColumns/index.js.map +1 -0
- package/lib/theme/GitBookColumns/styles.module.css +17 -0
- package/lib/theme/GitBookEmbed/index.d.ts +9 -0
- package/lib/theme/GitBookEmbed/index.d.ts.map +1 -0
- package/lib/theme/GitBookEmbed/index.js +71 -0
- package/lib/theme/GitBookEmbed/index.js.map +1 -0
- package/lib/theme/GitBookEmbed/styles.module.css +37 -0
- package/lib/theme/GitBookExpression/index.d.ts +13 -0
- package/lib/theme/GitBookExpression/index.d.ts.map +1 -0
- package/lib/theme/GitBookExpression/index.js +12 -0
- package/lib/theme/GitBookExpression/index.js.map +1 -0
- package/lib/theme/GitBookExpression/styles.module.css +16 -0
- package/lib/theme/GitBookFile/index.d.ts +9 -0
- package/lib/theme/GitBookFile/index.d.ts.map +1 -0
- package/lib/theme/GitBookFile/index.js +42 -0
- package/lib/theme/GitBookFile/index.js.map +1 -0
- package/lib/theme/GitBookFile/styles.module.css +61 -0
- package/lib/theme/GitBookInclude/index.d.ts +19 -0
- package/lib/theme/GitBookInclude/index.d.ts.map +1 -0
- package/lib/theme/GitBookInclude/index.js +8 -0
- package/lib/theme/GitBookInclude/index.js.map +1 -0
- package/lib/theme/GitBookInclude/styles.module.css +77 -0
- package/lib/theme/GitBookOpenAPI/index.d.ts +14 -0
- package/lib/theme/GitBookOpenAPI/index.d.ts.map +1 -0
- package/lib/theme/GitBookOpenAPI/index.js +73 -0
- package/lib/theme/GitBookOpenAPI/index.js.map +1 -0
- package/lib/theme/GitBookOpenAPI/styles.module.css +214 -0
- package/lib/theme/GitBookStep/index.d.ts +13 -0
- package/lib/theme/GitBookStep/index.d.ts.map +1 -0
- package/lib/theme/GitBookStep/index.js +6 -0
- package/lib/theme/GitBookStep/index.js.map +1 -0
- package/lib/theme/GitBookStep/styles.module.css +62 -0
- package/lib/theme/GitBookStepper/index.d.ts +9 -0
- package/lib/theme/GitBookStepper/index.d.ts.map +1 -0
- package/lib/theme/GitBookStepper/index.js +6 -0
- package/lib/theme/GitBookStepper/index.js.map +1 -0
- package/lib/theme/GitBookStepper/styles.module.css +7 -0
- package/lib/theme/GitBookTab/index.d.ts +12 -0
- package/lib/theme/GitBookTab/index.d.ts.map +1 -0
- package/lib/theme/GitBookTab/index.js +9 -0
- package/lib/theme/GitBookTab/index.js.map +1 -0
- package/lib/theme/GitBookTab/styles.module.css +15 -0
- package/lib/theme/GitBookTabs/index.d.ts +9 -0
- package/lib/theme/GitBookTabs/index.d.ts.map +1 -0
- package/lib/theme/GitBookTabs/index.js +32 -0
- package/lib/theme/GitBookTabs/index.js.map +1 -0
- package/lib/theme/GitBookTabs/styles.module.css +57 -0
- package/lib/theme/GitBookUpdate/index.d.ts +9 -0
- package/lib/theme/GitBookUpdate/index.d.ts.map +1 -0
- package/lib/theme/GitBookUpdate/index.js +21 -0
- package/lib/theme/GitBookUpdate/index.js.map +1 -0
- package/lib/theme/GitBookUpdate/styles.module.css +68 -0
- package/lib/theme/GitBookUpdates/index.d.ts +9 -0
- package/lib/theme/GitBookUpdates/index.d.ts.map +1 -0
- package/lib/theme/GitBookUpdates/index.js +6 -0
- package/lib/theme/GitBookUpdates/index.js.map +1 -0
- package/lib/theme/GitBookUpdates/styles.module.css +15 -0
- package/lib/theme/gitbook.css +205 -0
- package/lib/theme-types.d.ts +129 -0
- package/lib/theme-types.d.ts.map +1 -0
- package/lib/theme-types.js +5 -0
- package/lib/theme-types.js.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# docusaurus-plugin-gitbook
|
|
2
|
+
|
|
3
|
+
A [Docusaurus plugin](https://docusaurus.io/docs/advanced/plugins) that adds support for GitBook-specific block syntax in MDX files.
|
|
4
|
+
|
|
5
|
+
📖 **[Full Documentation](https://www.jasny.net/docusaurus-plugin-gitbook/)**
|
|
6
|
+
|
|
7
|
+
## Supported Blocks
|
|
8
|
+
|
|
9
|
+
| Block | Description | Docs |
|
|
10
|
+
|-------|-------------|------|
|
|
11
|
+
| Hints | Info, warning, danger, and success callouts | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/hints) |
|
|
12
|
+
| Tabs | Tabbed content panels | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/tabs) |
|
|
13
|
+
| Stepper | Numbered step-by-step guides | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/stepper) |
|
|
14
|
+
| Columns | Side-by-side column layouts | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/columns) |
|
|
15
|
+
| Code blocks | Code blocks with titles and line numbers | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/code) |
|
|
16
|
+
| Embeds | Embedded external content (YouTube, etc.) | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/embeds) |
|
|
17
|
+
| Files | File download links | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/files) |
|
|
18
|
+
| Buttons | Primary and secondary action buttons | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/buttons) |
|
|
19
|
+
| Cards | Card grid layouts | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/cards) |
|
|
20
|
+
| Icons | Font Awesome icons | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/icons) |
|
|
21
|
+
| OpenAPI | OpenAPI/Swagger endpoint documentation | [View](https://www.jasny.net/docusaurus-plugin-gitbook/blocks/openapi) |
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install docusaurus-plugin-gitbook
|
|
27
|
+
# or
|
|
28
|
+
yarn add docusaurus-plugin-gitbook
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
Add the plugin to your `docusaurus.config.js`:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
export default {
|
|
37
|
+
plugins: ['docusaurus-plugin-gitbook'],
|
|
38
|
+
|
|
39
|
+
// Or with options:
|
|
40
|
+
plugins: [
|
|
41
|
+
['docusaurus-plugin-gitbook', {
|
|
42
|
+
// options
|
|
43
|
+
}]
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Using as Remark/Rehype plugins directly
|
|
49
|
+
|
|
50
|
+
You can also use the remark and rehype plugins directly:
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import { remarkGitBook, rehypeGitBook } from 'docusaurus-plugin-gitbook';
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
presets: [
|
|
57
|
+
[
|
|
58
|
+
'@docusaurus/preset-classic',
|
|
59
|
+
{
|
|
60
|
+
docs: {
|
|
61
|
+
remarkPlugins: [remarkGitBook],
|
|
62
|
+
rehypePlugins: [rehypeGitBook],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
### Hint
|
|
73
|
+
|
|
74
|
+
```markdown
|
|
75
|
+
{% hint style="info" %}
|
|
76
|
+
This is an informational hint.
|
|
77
|
+
{% endhint %}
|
|
78
|
+
|
|
79
|
+
{% hint style="warning" %}
|
|
80
|
+
Be careful with this action.
|
|
81
|
+
{% endhint %}
|
|
82
|
+
|
|
83
|
+
{% hint style="danger" %}
|
|
84
|
+
This action cannot be undone!
|
|
85
|
+
{% endhint %}
|
|
86
|
+
|
|
87
|
+
{% hint style="success" %}
|
|
88
|
+
Operation completed successfully.
|
|
89
|
+
{% endhint %}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Tabs
|
|
93
|
+
|
|
94
|
+
```markdown
|
|
95
|
+
{% tabs %}
|
|
96
|
+
{% tab title="JavaScript" %}
|
|
97
|
+
\`\`\`javascript
|
|
98
|
+
console.log('Hello');
|
|
99
|
+
\`\`\`
|
|
100
|
+
{% endtab %}
|
|
101
|
+
|
|
102
|
+
{% tab title="Python" %}
|
|
103
|
+
\`\`\`python
|
|
104
|
+
print('Hello')
|
|
105
|
+
\`\`\`
|
|
106
|
+
{% endtab %}
|
|
107
|
+
{% endtabs %}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Stepper
|
|
111
|
+
|
|
112
|
+
```markdown
|
|
113
|
+
{% stepper %}
|
|
114
|
+
{% step %}
|
|
115
|
+
## Step 1
|
|
116
|
+
First step content.
|
|
117
|
+
{% endstep %}
|
|
118
|
+
|
|
119
|
+
{% step %}
|
|
120
|
+
## Step 2
|
|
121
|
+
Second step content.
|
|
122
|
+
{% endstep %}
|
|
123
|
+
{% endstepper %}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Columns
|
|
127
|
+
|
|
128
|
+
```markdown
|
|
129
|
+
{% columns %}
|
|
130
|
+
{% column %}
|
|
131
|
+
Left column content.
|
|
132
|
+
{% endcolumn %}
|
|
133
|
+
|
|
134
|
+
{% column %}
|
|
135
|
+
Right column content.
|
|
136
|
+
{% endcolumn %}
|
|
137
|
+
{% endcolumns %}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Code with Title
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
{% code title="example.js" %}
|
|
144
|
+
\`\`\`javascript
|
|
145
|
+
const foo = 'bar';
|
|
146
|
+
\`\`\`
|
|
147
|
+
{% endcode %}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Embed
|
|
151
|
+
|
|
152
|
+
```markdown
|
|
153
|
+
{% embed url="https://www.youtube.com/watch?v=VIDEO_ID" %}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### File
|
|
157
|
+
|
|
158
|
+
```markdown
|
|
159
|
+
{% file src="/path/to/file.pdf" %}
|
|
160
|
+
Optional description.
|
|
161
|
+
{% endfile %}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Button (HTML)
|
|
165
|
+
|
|
166
|
+
```html
|
|
167
|
+
<a href="https://example.com" class="button primary">Get Started</a>
|
|
168
|
+
<a href="https://docs.example.com" class="button secondary">Documentation</a>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Cards (HTML)
|
|
172
|
+
|
|
173
|
+
```html
|
|
174
|
+
<table data-view="cards">
|
|
175
|
+
<thead>
|
|
176
|
+
<tr>
|
|
177
|
+
<th>Title</th>
|
|
178
|
+
<th data-card-target data-type="content-ref">Target</th>
|
|
179
|
+
</tr>
|
|
180
|
+
</thead>
|
|
181
|
+
<tbody>
|
|
182
|
+
<tr>
|
|
183
|
+
<td>Getting Started</td>
|
|
184
|
+
<td><a href="getting-started.md">Quick Start</a></td>
|
|
185
|
+
</tr>
|
|
186
|
+
</tbody>
|
|
187
|
+
</table>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Styling
|
|
191
|
+
|
|
192
|
+
The plugin includes default styles that work with Docusaurus's light and dark themes. You can customize the appearance using CSS variables:
|
|
193
|
+
|
|
194
|
+
```css
|
|
195
|
+
:root {
|
|
196
|
+
--gitbook-hint-info-bg: #e7f3ff;
|
|
197
|
+
--gitbook-hint-info-border: #0969da;
|
|
198
|
+
--gitbook-hint-warning-bg: #fff8e6;
|
|
199
|
+
--gitbook-hint-warning-border: #9a6700;
|
|
200
|
+
--gitbook-hint-danger-bg: #ffebe9;
|
|
201
|
+
--gitbook-hint-danger-border: #cf222e;
|
|
202
|
+
--gitbook-hint-success-bg: #dafbe1;
|
|
203
|
+
--gitbook-hint-success-border: #1a7f37;
|
|
204
|
+
/* ... more variables */
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { LoadContext, Plugin } from '@docusaurus/types';
|
|
2
|
+
export { remarkGitBook } from './remark/index.js';
|
|
3
|
+
export type { RemarkGitBookOptions } from './remark/index.js';
|
|
4
|
+
export { rehypeGitBook } from './rehype/index.js';
|
|
5
|
+
export type { RehypeGitBookOptions } from './rehype/index.js';
|
|
6
|
+
export * from './parser/index.js';
|
|
7
|
+
export * from './theme-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Plugin options
|
|
10
|
+
*/
|
|
11
|
+
export interface PluginOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Plugin instance ID
|
|
14
|
+
*/
|
|
15
|
+
id?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Enable/disable specific blocks
|
|
18
|
+
*/
|
|
19
|
+
blocks?: {
|
|
20
|
+
hint?: boolean;
|
|
21
|
+
tabs?: boolean;
|
|
22
|
+
stepper?: boolean;
|
|
23
|
+
columns?: boolean;
|
|
24
|
+
updates?: boolean;
|
|
25
|
+
code?: boolean;
|
|
26
|
+
embed?: boolean;
|
|
27
|
+
file?: boolean;
|
|
28
|
+
include?: boolean;
|
|
29
|
+
openapi?: boolean;
|
|
30
|
+
cards?: boolean;
|
|
31
|
+
button?: boolean;
|
|
32
|
+
icon?: boolean;
|
|
33
|
+
expression?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Custom class name prefix for CSS
|
|
37
|
+
*/
|
|
38
|
+
classNamePrefix?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Docusaurus plugin for GitBook syntax support
|
|
42
|
+
*/
|
|
43
|
+
export default function pluginGitbook(_context: LoadContext, options?: PluginOptions): Plugin;
|
|
44
|
+
/**
|
|
45
|
+
* Validate plugin options
|
|
46
|
+
*/
|
|
47
|
+
export declare function validateOptions({ options, validate: _validate, }: {
|
|
48
|
+
options: PluginOptions;
|
|
49
|
+
validate: <T>(schema: unknown, options: T) => T;
|
|
50
|
+
}): PluginOptions;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAK7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,cAAc,mBAAmB,CAAC;AAGlC,cAAc,kBAAkB,CAAC;AAEjC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;IAEF;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAKD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAkBR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,QAAQ,EAAE,SAAS,GACpB,EAAE;IACD,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;CACjD,GAAG,aAAa,CAIhB"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
// Re-export remark plugin
|
|
4
|
+
export { remarkGitBook } from './remark/index.js';
|
|
5
|
+
// Re-export rehype plugin
|
|
6
|
+
export { rehypeGitBook } from './rehype/index.js';
|
|
7
|
+
// Re-export parser utilities
|
|
8
|
+
export * from './parser/index.js';
|
|
9
|
+
// Re-export theme types
|
|
10
|
+
export * from './theme-types.js';
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
/**
|
|
14
|
+
* Docusaurus plugin for GitBook syntax support
|
|
15
|
+
*/
|
|
16
|
+
export default function pluginGitbook(_context, options = {}) {
|
|
17
|
+
const { blocks: _blocks, classNamePrefix: _classNamePrefix } = options;
|
|
18
|
+
return {
|
|
19
|
+
name: 'docusaurus-plugin-gitbook',
|
|
20
|
+
getThemePath() {
|
|
21
|
+
return path.resolve(__dirname, './theme');
|
|
22
|
+
},
|
|
23
|
+
getTypeScriptThemePath() {
|
|
24
|
+
return path.resolve(__dirname, '../src/theme');
|
|
25
|
+
},
|
|
26
|
+
getClientModules() {
|
|
27
|
+
return [path.resolve(__dirname, './theme/gitbook.css')];
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validate plugin options
|
|
33
|
+
*/
|
|
34
|
+
export function validateOptions({ options, validate: _validate, }) {
|
|
35
|
+
// For now, just return options as-is
|
|
36
|
+
// In the future, we could add Joi schema validation
|
|
37
|
+
return options;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,6BAA6B;AAC7B,cAAc,mBAAmB,CAAC;AAElC,wBAAwB;AACxB,cAAc,kBAAkB,CAAC;AAqCjC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,QAAqB,EACrB,UAAyB,EAAE;IAE3B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAEvE,OAAO;QACL,IAAI,EAAE,2BAA2B;QAEjC,YAAY;YACV,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC;QAED,sBAAsB;YACpB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACjD,CAAC;QAED,gBAAgB;YACd,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,QAAQ,EAAE,SAAS,GAIpB;IACC,qCAAqC;IACrC,oDAAoD;IACpD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitBook parser exports
|
|
3
|
+
*/
|
|
4
|
+
export { tokenize, parseAttributes, isToken, isTextSegment, type Token, type TokenType, type TextSegment, type Segment, } from './tokenizer.js';
|
|
5
|
+
export { parse, findBlocks, extractBlocks, type GitBookBlock, type ParseResult, type ParseError, } from './parser.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EACR,eAAe,EACf,OAAO,EACP,aAAa,EACb,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,OAAO,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,KAAK,EACL,UAAU,EACV,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EACR,eAAe,EACf,OAAO,EACP,aAAa,GAKd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,KAAK,EACL,UAAU,EACV,aAAa,GAId,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitBook block parser
|
|
3
|
+
* Parses tokenized GitBook syntax into a structured tree
|
|
4
|
+
*/
|
|
5
|
+
export interface GitBookBlock {
|
|
6
|
+
name: string;
|
|
7
|
+
attributes: Record<string, string>;
|
|
8
|
+
content: string;
|
|
9
|
+
children: GitBookBlock[];
|
|
10
|
+
raw: string;
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ParseResult {
|
|
15
|
+
blocks: GitBookBlock[];
|
|
16
|
+
errors: ParseError[];
|
|
17
|
+
}
|
|
18
|
+
export interface ParseError {
|
|
19
|
+
message: string;
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse GitBook block syntax from text
|
|
25
|
+
*/
|
|
26
|
+
export declare function parse(text: string): ParseResult;
|
|
27
|
+
/**
|
|
28
|
+
* Find all blocks of a specific type in parsed result
|
|
29
|
+
*/
|
|
30
|
+
export declare function findBlocks(blocks: GitBookBlock[], name: string): GitBookBlock[];
|
|
31
|
+
/**
|
|
32
|
+
* Extract content between GitBook tags, returning both the content
|
|
33
|
+
* and remaining text
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractBlocks(text: string): {
|
|
36
|
+
blocks: GitBookBlock[];
|
|
37
|
+
textSegments: Array<{
|
|
38
|
+
content: string;
|
|
39
|
+
start: number;
|
|
40
|
+
end: number;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAsGD;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAyD/C;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,EAAE,EACtB,IAAI,EAAE,MAAM,GACX,YAAY,EAAE,CAWhB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,GACX;IAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,YAAY,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAqClG"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitBook block parser
|
|
3
|
+
* Parses tokenized GitBook syntax into a structured tree
|
|
4
|
+
*/
|
|
5
|
+
import { tokenize, isTextSegment, } from './tokenizer.js';
|
|
6
|
+
/**
|
|
7
|
+
* Parse a block starting from an open token
|
|
8
|
+
*/
|
|
9
|
+
function parseBlock(ctx, openToken) {
|
|
10
|
+
const children = [];
|
|
11
|
+
const contentParts = [];
|
|
12
|
+
while (ctx.index < ctx.segments.length) {
|
|
13
|
+
const segment = ctx.segments[ctx.index];
|
|
14
|
+
if (isTextSegment(segment)) {
|
|
15
|
+
contentParts.push(segment.content);
|
|
16
|
+
ctx.index++;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
// It's a token
|
|
20
|
+
if (segment.type === 'close' && segment.name === openToken.name) {
|
|
21
|
+
// Found matching close tag
|
|
22
|
+
ctx.index++;
|
|
23
|
+
const content = contentParts.join('');
|
|
24
|
+
const endPos = segment.end;
|
|
25
|
+
return {
|
|
26
|
+
name: openToken.name,
|
|
27
|
+
attributes: openToken.attributes,
|
|
28
|
+
content: content.trim(),
|
|
29
|
+
children,
|
|
30
|
+
raw: ctx.source.slice(openToken.start, endPos),
|
|
31
|
+
start: openToken.start,
|
|
32
|
+
end: endPos,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (segment.type === 'close') {
|
|
36
|
+
// Mismatched close tag - error
|
|
37
|
+
ctx.errors.push({
|
|
38
|
+
message: `Unexpected closing tag {% end${segment.name} %}, expected {% end${openToken.name} %}`,
|
|
39
|
+
start: segment.start,
|
|
40
|
+
end: segment.end,
|
|
41
|
+
});
|
|
42
|
+
ctx.index++;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (segment.type === 'self-closing') {
|
|
46
|
+
// Self-closing tag becomes a child
|
|
47
|
+
children.push({
|
|
48
|
+
name: segment.name,
|
|
49
|
+
attributes: segment.attributes,
|
|
50
|
+
content: '',
|
|
51
|
+
children: [],
|
|
52
|
+
raw: segment.raw,
|
|
53
|
+
start: segment.start,
|
|
54
|
+
end: segment.end,
|
|
55
|
+
});
|
|
56
|
+
ctx.index++;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (segment.type === 'open') {
|
|
60
|
+
// Nested block - recurse
|
|
61
|
+
ctx.index++;
|
|
62
|
+
const childBlock = parseBlock(ctx, segment);
|
|
63
|
+
if (childBlock) {
|
|
64
|
+
children.push(childBlock);
|
|
65
|
+
}
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
ctx.index++;
|
|
69
|
+
}
|
|
70
|
+
// Reached end without finding close tag
|
|
71
|
+
ctx.errors.push({
|
|
72
|
+
message: `Unclosed tag {% ${openToken.name} %}, expected {% end${openToken.name} %}`,
|
|
73
|
+
start: openToken.start,
|
|
74
|
+
end: openToken.end,
|
|
75
|
+
});
|
|
76
|
+
// Return what we have anyway
|
|
77
|
+
return {
|
|
78
|
+
name: openToken.name,
|
|
79
|
+
attributes: openToken.attributes,
|
|
80
|
+
content: contentParts.join('').trim(),
|
|
81
|
+
children,
|
|
82
|
+
raw: ctx.source.slice(openToken.start),
|
|
83
|
+
start: openToken.start,
|
|
84
|
+
end: ctx.source.length,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parse GitBook block syntax from text
|
|
89
|
+
*/
|
|
90
|
+
export function parse(text) {
|
|
91
|
+
const segments = tokenize(text);
|
|
92
|
+
const blocks = [];
|
|
93
|
+
const ctx = {
|
|
94
|
+
segments,
|
|
95
|
+
index: 0,
|
|
96
|
+
errors: [],
|
|
97
|
+
source: text,
|
|
98
|
+
};
|
|
99
|
+
while (ctx.index < segments.length) {
|
|
100
|
+
const segment = segments[ctx.index];
|
|
101
|
+
if (isTextSegment(segment)) {
|
|
102
|
+
// Skip top-level text
|
|
103
|
+
ctx.index++;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (segment.type === 'close') {
|
|
107
|
+
// Orphan close tag
|
|
108
|
+
ctx.errors.push({
|
|
109
|
+
message: `Unexpected closing tag {% end${segment.name} %} without matching open tag`,
|
|
110
|
+
start: segment.start,
|
|
111
|
+
end: segment.end,
|
|
112
|
+
});
|
|
113
|
+
ctx.index++;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (segment.type === 'self-closing') {
|
|
117
|
+
blocks.push({
|
|
118
|
+
name: segment.name,
|
|
119
|
+
attributes: segment.attributes,
|
|
120
|
+
content: '',
|
|
121
|
+
children: [],
|
|
122
|
+
raw: segment.raw,
|
|
123
|
+
start: segment.start,
|
|
124
|
+
end: segment.end,
|
|
125
|
+
});
|
|
126
|
+
ctx.index++;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (segment.type === 'open') {
|
|
130
|
+
ctx.index++;
|
|
131
|
+
const block = parseBlock(ctx, segment);
|
|
132
|
+
if (block) {
|
|
133
|
+
blocks.push(block);
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
ctx.index++;
|
|
138
|
+
}
|
|
139
|
+
return { blocks, errors: ctx.errors };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Find all blocks of a specific type in parsed result
|
|
143
|
+
*/
|
|
144
|
+
export function findBlocks(blocks, name) {
|
|
145
|
+
const result = [];
|
|
146
|
+
for (const block of blocks) {
|
|
147
|
+
if (block.name === name) {
|
|
148
|
+
result.push(block);
|
|
149
|
+
}
|
|
150
|
+
result.push(...findBlocks(block.children, name));
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Extract content between GitBook tags, returning both the content
|
|
156
|
+
* and remaining text
|
|
157
|
+
*/
|
|
158
|
+
export function extractBlocks(text) {
|
|
159
|
+
const textSegments = [];
|
|
160
|
+
const parseResult = parse(text);
|
|
161
|
+
// Collect text segments that are not part of any block
|
|
162
|
+
let lastBlockEnd = 0;
|
|
163
|
+
for (const block of parseResult.blocks) {
|
|
164
|
+
if (block.start > lastBlockEnd) {
|
|
165
|
+
const content = text.slice(lastBlockEnd, block.start);
|
|
166
|
+
if (content.trim()) {
|
|
167
|
+
textSegments.push({
|
|
168
|
+
content,
|
|
169
|
+
start: lastBlockEnd,
|
|
170
|
+
end: block.start,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
lastBlockEnd = block.end;
|
|
175
|
+
}
|
|
176
|
+
// Add trailing text
|
|
177
|
+
if (lastBlockEnd < text.length) {
|
|
178
|
+
const content = text.slice(lastBlockEnd);
|
|
179
|
+
if (content.trim()) {
|
|
180
|
+
textSegments.push({
|
|
181
|
+
content,
|
|
182
|
+
start: lastBlockEnd,
|
|
183
|
+
end: text.length,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
blocks: parseResult.blocks,
|
|
189
|
+
textSegments,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,QAAQ,EACR,aAAa,GAGd,MAAM,gBAAgB,CAAC;AA8BxB;;GAEG;AACH,SAAS,UAAU,CAAC,GAAiB,EAAE,SAAgB;IACrD,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,OAAO,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAExC,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACnC,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,SAAS;QACX,CAAC;QAED,eAAe;QACf,I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C3B,CAAC;IAED,oBAAoB;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACzC,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC;gBAChB,OAAO;gBACP,KAAK,EAAE,YAAY;gBACnB,GAAG,EAAE,IAAI,CAAC,MAAM;aACjB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitBook tag tokenizer
|
|
3
|
+
* Tokenizes {% tag %} syntax into structured tokens
|
|
4
|
+
*/
|
|
5
|
+
export type TokenType = 'open' | 'close' | 'self-closing';
|
|
6
|
+
export interface Token {
|
|
7
|
+
type: TokenType;
|
|
8
|
+
name: string;
|
|
9
|
+
attributes: Record<string, string>;
|
|
10
|
+
raw: string;
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
}
|
|
14
|
+
export interface TextSegment {
|
|
15
|
+
type: 'text';
|
|
16
|
+
content: string;
|
|
17
|
+
start: number;
|
|
18
|
+
end: number;
|
|
19
|
+
}
|
|
20
|
+
export type Segment = Token | TextSegment;
|
|
21
|
+
/**
|
|
22
|
+
* Parse attributes string into key-value pairs
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseAttributes(attrString: string): Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Tokenize text into segments (tokens and text)
|
|
27
|
+
*/
|
|
28
|
+
export declare function tokenize(text: string): Segment[];
|
|
29
|
+
/**
|
|
30
|
+
* Check if a segment is a token (not text)
|
|
31
|
+
*/
|
|
32
|
+
export declare function isToken(segment: Segment): segment is Token;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a segment is a text segment
|
|
35
|
+
*/
|
|
36
|
+
export declare function isTextSegment(segment: Segment): segment is TextSegment;
|
|
37
|
+
//# sourceMappingURL=tokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../src/parser/tokenizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;AAE1D,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,WAAW,CAAC;AAc1C;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqC1E;AAoFD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CA8ChD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,KAAK,CAE1D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,WAAW,CAEtE"}
|