Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/comark/SPEC/MDC/cjk.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
options:
plugins:
- cjk
---

## Input

```md
Expand Down
2 changes: 2 additions & 0 deletions packages/comark/SPEC/MDC/emoji-inside-component-autounwrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ timeout:
markdown: 5ms
options:
autoUnwrap: true
plugins:
- emoji
---

## Input
Expand Down
3 changes: 3 additions & 0 deletions packages/comark/SPEC/MDC/emoji-inside-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ timeout:
parse: 5ms
html: 5ms
markdown: 5ms
options:
plugins:
- emoji
---

## Input
Expand Down
3 changes: 3 additions & 0 deletions packages/comark/SPEC/MDC/emoji.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ timeout:
parse: 5ms
html: 5ms
markdown: 5ms
options:
plugins:
- emoji
---

## Input
Expand Down
30 changes: 24 additions & 6 deletions packages/comark/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import minLight from '@shikijs/themes/min-light'
import nord from '@shikijs/themes/nord'
import rustLanguage from '@shikijs/langs/rust'
import goLanguage from '@shikijs/langs/go'
import type { ParseOptions } from '../src/types'

type PluginName = 'cjk' | 'emoji'

const pluginRegistry: Record<PluginName, () => ComarkPlugin> = {
cjk,
emoji,
}

interface TestCase {
input: string
Expand All @@ -27,6 +35,8 @@ interface TestCase {
}
options?: {
highlight?: HighlightOptions
plugins?: PluginName[]
autoUnwrap?: boolean
}
}

Expand Down Expand Up @@ -176,7 +186,9 @@ describe('Comark Tests', () => {
let parsedAST: Awaited<ReturnType<typeof parse>>

beforeAll(async () => {
const plugins: ComarkPlugin[] = [cjk(), emoji()]
const declaredPlugins = testCase.options?.plugins ?? []
const plugins: ComarkPlugin[] = declaredPlugins.map(name => pluginRegistry[name]())

if (testCase.options?.highlight) {
const themes = {
'min-light': minLight,
Expand All @@ -193,11 +205,17 @@ describe('Comark Tests', () => {
},
}))
}
parsedAST = await parse(testCase.input, {
autoUnwrap: false,
...testCase.options,
plugins,
})

const parseOptions: ParseOptions = {
autoUnwrap: testCase.options?.autoUnwrap ?? false,
...testCase.options?.highlight ? { highlight: testCase.options.highlight } : {},
}

if (plugins.length > 0) {
parseOptions.plugins = plugins
}

parsedAST = await parse(testCase.input, parseOptions)
}, testCase.timeouts?.parse ?? 5000)

it('should parse input to AST', () => {
Expand Down
19 changes: 0 additions & 19 deletions packages/comark/test/roundtrip.test.ts

This file was deleted.

Loading