comark 0.3.1 → 0.3.2
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/dist/devtools/index.d.ts +1 -0
- package/dist/devtools/index.js +1 -0
- package/dist/devtools/register.d.ts +1 -0
- package/dist/devtools/register.js +1 -0
- package/dist/devtools/registry.d.ts +1 -0
- package/dist/devtools/registry.js +1 -0
- package/dist/devtools/vite.d.ts +1 -0
- package/dist/devtools/vite.js +1 -0
- package/dist/internal/frontmatter.d.ts +1 -0
- package/dist/internal/frontmatter.js +4 -2
- package/dist/internal/parse/auto-close/index.js +25 -13
- package/dist/internal/parse/auto-close/table.js +12 -9
- package/dist/internal/parse/auto-unwrap.js +2 -10
- package/dist/internal/parse/html/html_block_rule.js +1 -1
- package/dist/internal/parse/html/html_inline_rule.js +3 -7
- package/dist/internal/parse/html/html_re.js +1 -1
- package/dist/internal/parse/html/index.js +14 -2
- package/dist/internal/parse/syntax/block-params.d.ts +9 -0
- package/dist/internal/parse/syntax/block-params.js +48 -0
- package/dist/internal/parse/syntax/brackets.d.ts +8 -0
- package/dist/internal/parse/syntax/brackets.js +20 -0
- package/dist/internal/parse/syntax/props.d.ts +5 -0
- package/dist/internal/parse/syntax/props.js +119 -0
- package/dist/internal/parse/token-processor.js +25 -24
- package/dist/internal/props-validation.js +4 -9
- package/dist/internal/stringify/attributes.js +4 -1
- package/dist/internal/stringify/handlers/a.js +1 -3
- package/dist/internal/stringify/handlers/blockquote.js +2 -4
- package/dist/internal/stringify/handlers/code.js +1 -3
- package/dist/internal/stringify/handlers/emphesis.js +1 -3
- package/dist/internal/stringify/handlers/html.js +26 -16
- package/dist/internal/stringify/handlers/img.js +1 -3
- package/dist/internal/stringify/handlers/li.js +14 -8
- package/dist/internal/stringify/handlers/mdc.js +2 -3
- package/dist/internal/stringify/handlers/ol.js +1 -1
- package/dist/internal/stringify/handlers/p.d.ts +1 -1
- package/dist/internal/stringify/handlers/p.js +4 -1
- package/dist/internal/stringify/handlers/pre.js +10 -13
- package/dist/internal/stringify/handlers/strong.js +1 -3
- package/dist/internal/stringify/handlers/table.js +7 -5
- package/dist/internal/stringify/handlers/template.js +1 -1
- package/dist/internal/stringify/handlers/ul.js +1 -1
- package/dist/internal/stringify/indent.d.ts +1 -5
- package/dist/internal/stringify/indent.js +1 -9
- package/dist/internal/stringify/state.js +1 -1
- package/dist/internal/yaml.js +1 -1
- package/dist/parse.js +14 -8
- package/dist/plugins/alert.js +1 -1
- package/dist/plugins/binding.js +1 -3
- package/dist/plugins/breaks.js +1 -1
- package/dist/plugins/emoji.js +8 -8
- package/dist/plugins/footnotes.js +19 -13
- package/dist/plugins/headings.js +2 -4
- package/dist/plugins/highlight.d.ts +1 -11
- package/dist/plugins/highlight.js +198 -103
- package/dist/plugins/json-render.js +5 -9
- package/dist/plugins/math.js +4 -6
- package/dist/plugins/mermaid.js +6 -20
- package/dist/plugins/punctuation.js +5 -6
- package/dist/plugins/security.js +2 -2
- package/dist/plugins/syntax.d.ts +49 -0
- package/dist/plugins/syntax.js +522 -0
- package/dist/plugins/task-list.d.ts +1 -1
- package/dist/plugins/task-list.js +11 -8
- package/dist/plugins/toc.js +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/utils/comark.tmLanguage.d.ts +335 -0
- package/dist/utils/comark.tmLanguage.js +597 -0
- package/dist/utils/helpers.js +1 -3
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +25 -3
- package/package.json +39 -40
- package/skills/skills/comark/AGENTS.md +0 -261
- package/skills/skills/comark/SKILL.md +0 -489
- package/skills/skills/comark/references/markdown-syntax.md +0 -599
- package/skills/skills/comark/references/parsing-ast.md +0 -378
- package/skills/skills/comark/references/rendering-react.md +0 -445
- package/skills/skills/comark/references/rendering-svelte.md +0 -453
- package/skills/skills/comark/references/rendering-vue.md +0 -462
- /package/skills/{skills/migrate-mdc-to-comark → migrate-mdc-to-comark}/SKILL.md +0 -0
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
# Vue Rendering Guide
|
|
2
|
-
|
|
3
|
-
Complete guide for rendering Comark AST in Vue applications.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Basic Usage](#basic-usage)
|
|
8
|
-
- [Custom Components](#custom-components)
|
|
9
|
-
- [Dynamic Component Resolution](#dynamic-component-resolution)
|
|
10
|
-
- [Slots Support](#slots-support)
|
|
11
|
-
- [Streaming Mode](#streaming-mode)
|
|
12
|
-
- [Prose Components](#prose-components)
|
|
13
|
-
- [Error Handling](#error-handling)
|
|
14
|
-
- [Props Access](#props-access)
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Basic Usage
|
|
19
|
-
|
|
20
|
-
Use the `Comark` component to render markdown:
|
|
21
|
-
|
|
22
|
-
```vue
|
|
23
|
-
<template>
|
|
24
|
-
<Comark>{{ content }}</Comark>
|
|
25
|
-
</template>
|
|
26
|
-
|
|
27
|
-
<script setup lang="ts">
|
|
28
|
-
import { Comark } from '@comark/vue'
|
|
29
|
-
|
|
30
|
-
const content = `
|
|
31
|
-
# Hello World
|
|
32
|
-
|
|
33
|
-
This is **markdown** content.
|
|
34
|
-
|
|
35
|
-
::alert{type="info"}
|
|
36
|
-
Important message
|
|
37
|
-
::
|
|
38
|
-
`
|
|
39
|
-
</script>
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Custom Components
|
|
45
|
-
|
|
46
|
-
Map custom Vue components to Comark elements:
|
|
47
|
-
|
|
48
|
-
```vue
|
|
49
|
-
<template>
|
|
50
|
-
<Comark :components="customComponents">{{ content }}</Comark>
|
|
51
|
-
</template>
|
|
52
|
-
|
|
53
|
-
<script setup lang="ts">
|
|
54
|
-
import { Comark } from '@comark/vue'
|
|
55
|
-
import CustomHeading from './CustomHeading.vue'
|
|
56
|
-
import CustomAlert from './CustomAlert.vue'
|
|
57
|
-
import CustomCard from './CustomCard.vue'
|
|
58
|
-
|
|
59
|
-
const customComponents = {
|
|
60
|
-
h1: CustomHeading,
|
|
61
|
-
h2: CustomHeading,
|
|
62
|
-
alert: CustomAlert,
|
|
63
|
-
card: CustomCard,
|
|
64
|
-
}
|
|
65
|
-
</script>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Custom Component Example
|
|
69
|
-
|
|
70
|
-
```vue
|
|
71
|
-
<!-- CustomHeading.vue -->
|
|
72
|
-
<template>
|
|
73
|
-
<component :is="tag" :id="id" class="custom-heading">
|
|
74
|
-
<slot />
|
|
75
|
-
</component>
|
|
76
|
-
</template>
|
|
77
|
-
|
|
78
|
-
<script setup lang="ts">
|
|
79
|
-
import { computed } from 'vue'
|
|
80
|
-
|
|
81
|
-
const props = defineProps<{
|
|
82
|
-
__node: any // Comark node
|
|
83
|
-
}>()
|
|
84
|
-
|
|
85
|
-
const tag = computed(() => props.__node[0])
|
|
86
|
-
const id = computed(() => props.__node[1]?.id)
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<style scoped>
|
|
90
|
-
.custom-heading {
|
|
91
|
-
font-family: 'Inter', sans-serif;
|
|
92
|
-
font-weight: 700;
|
|
93
|
-
margin-bottom: 1rem;
|
|
94
|
-
}
|
|
95
|
-
</style>
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Alert Component Example
|
|
99
|
-
|
|
100
|
-
```vue
|
|
101
|
-
<!-- CustomAlert.vue -->
|
|
102
|
-
<template>
|
|
103
|
-
<div :class="`alert alert-${type}`" role="alert">
|
|
104
|
-
<div class="alert-icon">
|
|
105
|
-
<Icon :name="iconName" />
|
|
106
|
-
</div>
|
|
107
|
-
<div class="alert-content">
|
|
108
|
-
<slot />
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
</template>
|
|
112
|
-
|
|
113
|
-
<script setup lang="ts">
|
|
114
|
-
import { computed } from 'vue'
|
|
115
|
-
|
|
116
|
-
const props = defineProps<{
|
|
117
|
-
type?: 'info' | 'warning' | 'error' | 'success'
|
|
118
|
-
__node?: any
|
|
119
|
-
}>()
|
|
120
|
-
|
|
121
|
-
const iconName = computed(() => {
|
|
122
|
-
switch (props.type) {
|
|
123
|
-
case 'info': return 'info-circle'
|
|
124
|
-
case 'warning': return 'exclamation-triangle'
|
|
125
|
-
case 'error': return 'times-circle'
|
|
126
|
-
case 'success': return 'check-circle'
|
|
127
|
-
default: return 'info-circle'
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
</script>
|
|
131
|
-
|
|
132
|
-
<style scoped>
|
|
133
|
-
.alert {
|
|
134
|
-
display: flex;
|
|
135
|
-
padding: 1rem;
|
|
136
|
-
border-radius: 0.5rem;
|
|
137
|
-
margin-bottom: 1rem;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.alert-info {
|
|
141
|
-
background-color: #e3f2fd;
|
|
142
|
-
color: #1976d2;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.alert-warning {
|
|
146
|
-
background-color: #fff3e0;
|
|
147
|
-
color: #f57c00;
|
|
148
|
-
}
|
|
149
|
-
</style>
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## Dynamic Component Resolution
|
|
155
|
-
|
|
156
|
-
Load components dynamically using `componentsManifest`:
|
|
157
|
-
|
|
158
|
-
```vue
|
|
159
|
-
<template>
|
|
160
|
-
<Comark
|
|
161
|
-
:components-manifest="loadComponent"
|
|
162
|
-
>{{ content }}</Comark>
|
|
163
|
-
</template>
|
|
164
|
-
|
|
165
|
-
<script setup lang="ts">
|
|
166
|
-
import { Comark } from '@comark/vue'
|
|
167
|
-
|
|
168
|
-
const componentMap = {
|
|
169
|
-
'alert': () => import('./Alert.vue'),
|
|
170
|
-
'card': () => import('./Card.vue'),
|
|
171
|
-
'button': () => import('./Button.vue'),
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async function loadComponent(name: string) {
|
|
175
|
-
if (componentMap[name]) {
|
|
176
|
-
return componentMap[name]()
|
|
177
|
-
}
|
|
178
|
-
throw new Error(`Component ${name} not found`)
|
|
179
|
-
}
|
|
180
|
-
</script>
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
## Slots Support
|
|
186
|
-
|
|
187
|
-
Comark components with slots work seamlessly in Vue:
|
|
188
|
-
|
|
189
|
-
### Markdown with Slots
|
|
190
|
-
|
|
191
|
-
```markdown
|
|
192
|
-
::card
|
|
193
|
-
#header
|
|
194
|
-
## Card Title
|
|
195
|
-
|
|
196
|
-
#content
|
|
197
|
-
Main content here with **markdown** support
|
|
198
|
-
|
|
199
|
-
#footer
|
|
200
|
-
Footer text
|
|
201
|
-
::
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Custom Component with Slots
|
|
205
|
-
|
|
206
|
-
```vue
|
|
207
|
-
<!-- Card.vue -->
|
|
208
|
-
<template>
|
|
209
|
-
<div class="card">
|
|
210
|
-
<div v-if="$slots.header" class="card-header">
|
|
211
|
-
<slot name="header" />
|
|
212
|
-
</div>
|
|
213
|
-
<div class="card-content">
|
|
214
|
-
<slot name="content" />
|
|
215
|
-
<!-- Default slot as fallback -->
|
|
216
|
-
<slot />
|
|
217
|
-
</div>
|
|
218
|
-
<div v-if="$slots.footer" class="card-footer">
|
|
219
|
-
<slot name="footer" />
|
|
220
|
-
</div>
|
|
221
|
-
</div>
|
|
222
|
-
</template>
|
|
223
|
-
|
|
224
|
-
<style scoped>
|
|
225
|
-
.card {
|
|
226
|
-
border: 1px solid #e5e7eb;
|
|
227
|
-
border-radius: 0.5rem;
|
|
228
|
-
overflow: hidden;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.card-header {
|
|
232
|
-
background-color: #f9fafb;
|
|
233
|
-
padding: 1rem;
|
|
234
|
-
border-bottom: 1px solid #e5e7eb;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.card-content {
|
|
238
|
-
padding: 1rem;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.card-footer {
|
|
242
|
-
background-color: #f9fafb;
|
|
243
|
-
padding: 1rem;
|
|
244
|
-
border-top: 1px solid #e5e7eb;
|
|
245
|
-
}
|
|
246
|
-
</style>
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### Nested Slots
|
|
250
|
-
|
|
251
|
-
```markdown
|
|
252
|
-
::tabs
|
|
253
|
-
#tab1
|
|
254
|
-
### First Tab
|
|
255
|
-
Content for tab 1
|
|
256
|
-
|
|
257
|
-
#tab2
|
|
258
|
-
### Second Tab
|
|
259
|
-
Content for tab 2
|
|
260
|
-
::
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
```vue
|
|
264
|
-
<!-- Tabs.vue -->
|
|
265
|
-
<template>
|
|
266
|
-
<div class="tabs">
|
|
267
|
-
<div class="tab-headers">
|
|
268
|
-
<button
|
|
269
|
-
v-for="(slot, name) in $slots"
|
|
270
|
-
:key="name"
|
|
271
|
-
:class="{ active: activeTab === name }"
|
|
272
|
-
@click="activeTab = name"
|
|
273
|
-
>
|
|
274
|
-
{{ name }}
|
|
275
|
-
</button>
|
|
276
|
-
</div>
|
|
277
|
-
<div class="tab-content">
|
|
278
|
-
<component :is="() => $slots[activeTab]?.()" />
|
|
279
|
-
</div>
|
|
280
|
-
</div>
|
|
281
|
-
</template>
|
|
282
|
-
|
|
283
|
-
<script setup lang="ts">
|
|
284
|
-
import { ref } from 'vue'
|
|
285
|
-
|
|
286
|
-
const activeTab = ref('tab1')
|
|
287
|
-
</script>
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## Streaming Mode
|
|
293
|
-
|
|
294
|
-
The `Comark` component can be used with reactive content for streaming scenarios:
|
|
295
|
-
|
|
296
|
-
```vue
|
|
297
|
-
<template>
|
|
298
|
-
<div>
|
|
299
|
-
<Comark>{{ content }}</Comark>
|
|
300
|
-
<div v-if="isLoading">Loading...</div>
|
|
301
|
-
</div>
|
|
302
|
-
</template>
|
|
303
|
-
|
|
304
|
-
<script setup lang="ts">
|
|
305
|
-
import { ref } from 'vue'
|
|
306
|
-
import { Comark } from '@comark/vue'
|
|
307
|
-
|
|
308
|
-
const content = ref('')
|
|
309
|
-
const isLoading = ref(true)
|
|
310
|
-
|
|
311
|
-
async function loadContent() {
|
|
312
|
-
const response = await fetch('/api/content.md')
|
|
313
|
-
const reader = response.body!.getReader()
|
|
314
|
-
const decoder = new TextDecoder()
|
|
315
|
-
|
|
316
|
-
while (true) {
|
|
317
|
-
const { done, value } = await reader.read()
|
|
318
|
-
if (done) break
|
|
319
|
-
content.value += decoder.decode(value)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
isLoading.value = false
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
loadContent()
|
|
326
|
-
</script>
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
---
|
|
330
|
-
|
|
331
|
-
---
|
|
332
|
-
|
|
333
|
-
## Prose Components
|
|
334
|
-
|
|
335
|
-
The `Comark` component uses built-in prose styling automatically. You can override with custom components:
|
|
336
|
-
|
|
337
|
-
```vue
|
|
338
|
-
<template>
|
|
339
|
-
<Comark :components="components">{{ content }}</Comark>
|
|
340
|
-
</template>
|
|
341
|
-
|
|
342
|
-
<script setup lang="ts">
|
|
343
|
-
import { Comark } from '@comark/vue'
|
|
344
|
-
import CustomAlert from './CustomAlert.vue'
|
|
345
|
-
|
|
346
|
-
const components = {
|
|
347
|
-
alert: CustomAlert, // Override or add custom components
|
|
348
|
-
}
|
|
349
|
-
</script>
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
---
|
|
353
|
-
|
|
354
|
-
## Error Handling
|
|
355
|
-
|
|
356
|
-
The `ComarkRenderer` component has built-in error capture via Vue's `onErrorCaptured` hook. Component rendering errors are caught automatically without crashing the application. You can also use Vue's native `onErrorCaptured` in a parent component to handle errors:
|
|
357
|
-
|
|
358
|
-
```vue
|
|
359
|
-
<template>
|
|
360
|
-
<Comark :markdown="content" />
|
|
361
|
-
</template>
|
|
362
|
-
|
|
363
|
-
<script setup lang="ts">
|
|
364
|
-
import { onErrorCaptured } from 'vue'
|
|
365
|
-
import { Comark } from '@comark/vue'
|
|
366
|
-
|
|
367
|
-
onErrorCaptured((error) => {
|
|
368
|
-
console.error('Component error:', error)
|
|
369
|
-
return false // prevent propagation
|
|
370
|
-
})
|
|
371
|
-
</script>
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
---
|
|
375
|
-
|
|
376
|
-
## Props Access
|
|
377
|
-
|
|
378
|
-
Custom components receive the original Comark node and parsed props:
|
|
379
|
-
|
|
380
|
-
```vue
|
|
381
|
-
<!-- CustomAlert.vue -->
|
|
382
|
-
<template>
|
|
383
|
-
<div :class="alertClasses" role="alert">
|
|
384
|
-
<slot />
|
|
385
|
-
</div>
|
|
386
|
-
</template>
|
|
387
|
-
|
|
388
|
-
<script setup lang="ts">
|
|
389
|
-
import { computed } from 'vue'
|
|
390
|
-
|
|
391
|
-
const props = defineProps<{
|
|
392
|
-
type?: string // From {type="info"}
|
|
393
|
-
bool?: boolean // From {bool} → :bool="true"
|
|
394
|
-
count?: number // From {:count="5"}
|
|
395
|
-
data?: object // From {:data='{"key":"val"}'}
|
|
396
|
-
__node?: any // Original Comark node
|
|
397
|
-
}>()
|
|
398
|
-
|
|
399
|
-
const alertClasses = computed(() => [
|
|
400
|
-
'alert',
|
|
401
|
-
`alert-${props.type || 'info'}`,
|
|
402
|
-
{ 'alert-important': props.bool }
|
|
403
|
-
])
|
|
404
|
-
</script>
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
### Property Parsing Rules
|
|
408
|
-
|
|
409
|
-
- Props starting with `:` are parsed as booleans/JSON
|
|
410
|
-
- Standard HTML attributes work normally
|
|
411
|
-
- `__node` provides access to the raw AST node
|
|
412
|
-
|
|
413
|
-
### Accessing Node Structure
|
|
414
|
-
|
|
415
|
-
```vue
|
|
416
|
-
<script setup lang="ts">
|
|
417
|
-
const props = defineProps<{ __node?: any }>()
|
|
418
|
-
|
|
419
|
-
// Node structure: [tag, props, ...children]
|
|
420
|
-
const tag = computed(() => props.__node?.[0])
|
|
421
|
-
const nodeProps = computed(() => props.__node?.[1] || {})
|
|
422
|
-
const children = computed(() => props.__node?.slice(2) || [])
|
|
423
|
-
</script>
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
### Working with Complex Props
|
|
427
|
-
|
|
428
|
-
```vue
|
|
429
|
-
<!-- DataTable.vue -->
|
|
430
|
-
<template>
|
|
431
|
-
<table>
|
|
432
|
-
<thead>
|
|
433
|
-
<tr>
|
|
434
|
-
<th v-for="col in columns" :key="col">{{ col }}</th>
|
|
435
|
-
</tr>
|
|
436
|
-
</thead>
|
|
437
|
-
<tbody>
|
|
438
|
-
<slot />
|
|
439
|
-
</tbody>
|
|
440
|
-
</table>
|
|
441
|
-
</template>
|
|
442
|
-
|
|
443
|
-
<script setup lang="ts">
|
|
444
|
-
const props = defineProps<{
|
|
445
|
-
columns?: string[] // From {:columns='["Name","Age"]'}
|
|
446
|
-
sortable?: boolean // From {sortable}
|
|
447
|
-
__node?: any
|
|
448
|
-
}>()
|
|
449
|
-
</script>
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
**Usage in Markdown:**
|
|
453
|
-
|
|
454
|
-
```markdown
|
|
455
|
-
::data-table{:columns='["Name", "Age", "Email"]' sortable}
|
|
456
|
-
Table content here
|
|
457
|
-
::
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
---
|
|
461
|
-
|
|
462
|
-
[← Back to Main Skills Guide](../SKILL.md)
|
|
File without changes
|