-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
773910a
commit 79df18a
Showing
9 changed files
with
88 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
proseWrap: always | ||
semi: false | ||
singleQuote: true | ||
trailingComma: all | ||
trailingComma: none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { type PlaywrightTestConfig } from '@playwright/test'; | ||
import { type PlaywrightTestConfig } from '@playwright/test' | ||
|
||
const config: PlaywrightTestConfig = { | ||
testMatch: /test\/test\.ts$/, | ||
metadata: {}, | ||
}; | ||
metadata: {} | ||
} | ||
|
||
export default config; | ||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { type RemarkMermaidOptions } from 'remark-mermaidjs'; | ||
import { type RemarkMermaidOptions } from 'remark-mermaidjs' | ||
|
||
export const options: RemarkMermaidOptions = { | ||
errorFallback(node, error, vfile) { | ||
return { | ||
type: 'code', | ||
value: `${vfile.basename}\n\n${error}\n\n${JSON.stringify(node, undefined, 2)}`, | ||
}; | ||
}, | ||
}; | ||
value: `${vfile.basename}\n\n${error}\n\n${JSON.stringify(node, undefined, 2)}` | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { type RemarkMermaidOptions } from 'remark-mermaidjs'; | ||
import { type RemarkMermaidOptions } from 'remark-mermaidjs' | ||
|
||
export const options: RemarkMermaidOptions = { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
errorFallback() {}, | ||
}; | ||
errorFallback() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { type RemarkMermaidOptions } from 'remark-mermaidjs'; | ||
import { type RemarkMermaidOptions } from 'remark-mermaidjs' | ||
|
||
export const options: RemarkMermaidOptions = { | ||
mermaidConfig: { | ||
theme: 'forest', | ||
}, | ||
}; | ||
theme: 'forest' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# No medmaid | ||
|
||
```js | ||
console.log('This is a JavaScript code block'); | ||
console.log('This is a JavaScript code block') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
import { readdir, readFile } from 'node:fs/promises'; | ||
import { readdir, readFile } from 'node:fs/promises' | ||
|
||
import { expect, test } from '@playwright/test'; | ||
import rehypeStringify from 'rehype-stringify'; | ||
import { remark } from 'remark'; | ||
import remarkRehype from 'remark-rehype'; | ||
import { VFile } from 'vfile'; | ||
import { expect, test } from '@playwright/test' | ||
import rehypeStringify from 'rehype-stringify' | ||
import { remark } from 'remark' | ||
import remarkRehype from 'remark-rehype' | ||
import { VFile } from 'vfile' | ||
|
||
import remarkMermaid, { type RemarkMermaidOptions } from '../index.js'; | ||
import remarkMermaid, { type RemarkMermaidOptions } from '../index.js' | ||
|
||
const fixtures = new URL('fixtures/', import.meta.url); | ||
const fixtureNames = await readdir(fixtures); | ||
const fixtures = new URL('fixtures/', import.meta.url) | ||
const fixtureNames = await readdir(fixtures) | ||
|
||
test.describe.parallel('node', () => { | ||
for (const name of fixtureNames) { | ||
// eslint-disable-next-line no-empty-pattern | ||
test(name, async ({}, testInfo) => { | ||
testInfo.snapshotSuffix = 'node'; | ||
const fixture = new URL(`${name}/`, fixtures); | ||
const value = await readFile(new URL('input.md', fixture)); | ||
let options: RemarkMermaidOptions | undefined; | ||
testInfo.snapshotSuffix = 'node' | ||
const fixture = new URL(`${name}/`, fixtures) | ||
const value = await readFile(new URL('input.md', fixture)) | ||
let options: RemarkMermaidOptions | undefined | ||
try { | ||
({ options } = await import(String(new URL('options.ts', fixture)))); | ||
;({ options } = await import(String(new URL('options.ts', fixture)))) | ||
} catch { | ||
// This test case uses default options. | ||
} | ||
const processor = remark().use(remarkMermaid, options); | ||
const asMarkdown = await processor.process({ path: `${name}/input.md`, value }); | ||
const processor = remark().use(remarkMermaid, options) | ||
const asMarkdown = await processor.process({ path: `${name}/input.md`, value }) | ||
const asHTML = await processor() | ||
.use(remarkRehype) | ||
.use(rehypeStringify) | ||
.process({ path: `${name}/input.md`, value }); | ||
expect(asMarkdown.value).toMatchSnapshot({ name: `${name}.md` }); | ||
expect(asHTML.value).toMatchSnapshot({ name: `${name}.html` }); | ||
}); | ||
.process({ path: `${name}/input.md`, value }) | ||
expect(asMarkdown.value).toMatchSnapshot({ name: `${name}.md` }) | ||
expect(asHTML.value).toMatchSnapshot({ name: `${name}.html` }) | ||
}) | ||
} | ||
|
||
test('it should throw a vfile error if a diagram is invalid without error fallback', async () => { | ||
const processor = remark().use(remarkMermaid); | ||
const file = new VFile('```mermaid\ninvalid\n```\n'); | ||
const processor = remark().use(remarkMermaid) | ||
const file = new VFile('```mermaid\ninvalid\n```\n') | ||
await expect(() => processor.process(file)).rejects.toThrowError( | ||
'No diagram type detected matching given configuration for text: invalid', | ||
); | ||
expect(file.messages).toHaveLength(1); | ||
'No diagram type detected matching given configuration for text: invalid' | ||
) | ||
expect(file.messages).toHaveLength(1) | ||
expect(file.messages[0].message).toBe( | ||
'No diagram type detected matching given configuration for text: invalid', | ||
); | ||
expect(file.messages[0].source).toBe('remark-mermaidjs'); | ||
expect(file.messages[0].ruleId).toBe('remark-mermaidjs'); | ||
expect(file.messages[0].fatal).toBe(true); | ||
'No diagram type detected matching given configuration for text: invalid' | ||
) | ||
expect(file.messages[0].source).toBe('remark-mermaidjs') | ||
expect(file.messages[0].ruleId).toBe('remark-mermaidjs') | ||
expect(file.messages[0].fatal).toBe(true) | ||
expect(file.messages[0].position).toStrictEqual({ | ||
start: { offset: 0, line: 1, column: 1 }, | ||
end: { offset: 22, line: 3, column: 4 }, | ||
}); | ||
}); | ||
}); | ||
end: { offset: 22, line: 3, column: 4 } | ||
}) | ||
}) | ||
}) |