@tnotesjs/core 0.4.1 → 0.5.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.
@@ -1,57 +0,0 @@
1
- import { parseMarkdown } from '@tnotesjs/mindmap-core'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
- import { fileURLToPath } from 'node:url'
5
- import { describe, expect, it } from 'vitest'
6
-
7
- import {
8
- normalizeMindmapMarkdown,
9
- parseMarkmapFence,
10
- parseMindmapReference,
11
- } from './compat'
12
-
13
- const tnotesRoot = path.resolve(fileURLToPath(new URL('../../../../', import.meta.url)))
14
- const noteFiles = [
15
- 'TNotes.canvas/notes/0035. 使用 ctx.drawImage 引入图像/README.md',
16
- 'TNotes.docs/notes/0013. Mindmap/README.md',
17
- 'TNotes.docs/notes/0014. 分仓库模式/README.md',
18
- 'TNotes.javascript/notes/0070. CommonJS/README.md',
19
- 'TNotes.javascript/notes/0071. ESM/README.md',
20
- 'TNotes.sql/notes/0001. MySQL 8 从入门到精通/README.md',
21
- 'TNotes.vite/notes/0014. vite 思维导图/README.md',
22
- ].map((relative) => path.join(tnotesRoot, relative))
23
-
24
- const corpusAvailable = noteFiles.every((file) => fs.existsSync(file))
25
-
26
- describe.skipIf(!corpusAvailable)('legacy TNotes markmap corpus', () => {
27
- it('normalizes every historical block into valid mindmap-core Markdown', () => {
28
- const diagnostics: string[] = []
29
- let blockCount = 0
30
-
31
- for (const noteFile of noteFiles) {
32
- const note = fs.readFileSync(noteFile, 'utf8')
33
- const blocks = note.matchAll(/^(```(?:mindmap|markmap)[^\n]*)\n([\s\S]*?)^```\s*$/gm)
34
- for (const match of blocks) {
35
- blockCount += 1
36
- const options = parseMarkmapFence(match[1])
37
- let source = match[2]
38
- const reference = parseMindmapReference(
39
- source.split('\n').find((line) => line.trim()) ?? '',
40
- )
41
- if (reference) {
42
- source = fs.readFileSync(path.resolve(path.dirname(noteFile), reference.path), 'utf8')
43
- }
44
- const normalized = normalizeMindmapMarkdown(source, {
45
- title: options.title || reference?.title,
46
- })
47
- const result = parseMarkdown(normalized, path.basename(noteFile))
48
- if (!result.valid) {
49
- diagnostics.push(`${noteFile}\n${result.diagnostics.map((item) => item.message).join('\n')}`)
50
- }
51
- }
52
- }
53
-
54
- expect(blockCount).toBe(16)
55
- expect(diagnostics).toEqual([])
56
- })
57
- })