1
- import { test , expect } from 'vitest' ;
2
- import { headerIsMarkdown , isMarkdownFile , MarkdownBlockStateTracker } from './markdownUtils' ;
1
+ import { test , expect } from "vitest" ;
2
+ import {
3
+ headerIsMarkdown ,
4
+ isMarkdownFile ,
5
+ MarkdownBlockStateTracker ,
6
+ } from "./markdownUtils" ;
3
7
4
- test ( ' headerIsMarkdown correctly identifies markdown headers' , ( ) => {
8
+ test ( " headerIsMarkdown correctly identifies markdown headers" , ( ) => {
5
9
// Should return true for markdown headers
6
- expect ( headerIsMarkdown ( 'md' ) ) . toBe ( true ) ;
7
- expect ( headerIsMarkdown ( ' markdown' ) ) . toBe ( true ) ;
8
- expect ( headerIsMarkdown ( ' gfm' ) ) . toBe ( true ) ;
9
- expect ( headerIsMarkdown ( ' github-markdown' ) ) . toBe ( true ) ;
10
- expect ( headerIsMarkdown ( ' language md' ) ) . toBe ( true ) ;
11
- expect ( headerIsMarkdown ( ' language markdown' ) ) . toBe ( true ) ;
12
- expect ( headerIsMarkdown ( ' filename.md' ) ) . toBe ( true ) ;
13
- expect ( headerIsMarkdown ( ' path/to/file.md language' ) ) . toBe ( true ) ;
10
+ expect ( headerIsMarkdown ( "md" ) ) . toBe ( true ) ;
11
+ expect ( headerIsMarkdown ( " markdown" ) ) . toBe ( true ) ;
12
+ expect ( headerIsMarkdown ( " gfm" ) ) . toBe ( true ) ;
13
+ expect ( headerIsMarkdown ( " github-markdown" ) ) . toBe ( true ) ;
14
+ expect ( headerIsMarkdown ( " language md" ) ) . toBe ( true ) ;
15
+ expect ( headerIsMarkdown ( " language markdown" ) ) . toBe ( true ) ;
16
+ expect ( headerIsMarkdown ( " filename.md" ) ) . toBe ( true ) ;
17
+ expect ( headerIsMarkdown ( " path/to/file.md language" ) ) . toBe ( true ) ;
14
18
15
19
// Should return false for non-markdown headers
16
- expect ( headerIsMarkdown ( ' javascript' ) ) . toBe ( false ) ;
17
- expect ( headerIsMarkdown ( ' typescript' ) ) . toBe ( false ) ;
18
- expect ( headerIsMarkdown ( ' python' ) ) . toBe ( false ) ;
19
- expect ( headerIsMarkdown ( '' ) ) . toBe ( false ) ;
20
+ expect ( headerIsMarkdown ( " javascript" ) ) . toBe ( false ) ;
21
+ expect ( headerIsMarkdown ( " typescript" ) ) . toBe ( false ) ;
22
+ expect ( headerIsMarkdown ( " python" ) ) . toBe ( false ) ;
23
+ expect ( headerIsMarkdown ( "" ) ) . toBe ( false ) ;
20
24
} ) ;
21
25
22
- test ( ' isMarkdownFile correctly identifies markdown files' , ( ) => {
26
+ test ( " isMarkdownFile correctly identifies markdown files" , ( ) => {
23
27
// Should return true for markdown files
24
- expect ( isMarkdownFile ( ' test.md' ) ) . toBe ( true ) ;
25
- expect ( isMarkdownFile ( ' path/to/file.markdown' ) ) . toBe ( true ) ;
26
- expect ( isMarkdownFile ( ' README.md' ) ) . toBe ( true ) ;
28
+ expect ( isMarkdownFile ( " test.md" ) ) . toBe ( true ) ;
29
+ expect ( isMarkdownFile ( " path/to/file.markdown" ) ) . toBe ( true ) ;
30
+ expect ( isMarkdownFile ( " README.md" ) ) . toBe ( true ) ;
27
31
28
32
// Should return false for non-markdown files
29
- expect ( isMarkdownFile ( ' test.js' ) ) . toBe ( false ) ;
30
- expect ( isMarkdownFile ( ' script.ts' ) ) . toBe ( false ) ;
31
- expect ( isMarkdownFile ( '' ) ) . toBe ( false ) ;
33
+ expect ( isMarkdownFile ( " test.js" ) ) . toBe ( false ) ;
34
+ expect ( isMarkdownFile ( " script.ts" ) ) . toBe ( false ) ;
35
+ expect ( isMarkdownFile ( "" ) ) . toBe ( false ) ;
32
36
expect ( isMarkdownFile ( undefined ) ) . toBe ( false ) ;
33
37
} ) ;
34
38
35
- test ( ' MarkdownBlockStateTracker correctly tracks nested markdown blocks' , ( ) => {
39
+ test ( " MarkdownBlockStateTracker correctly tracks nested markdown blocks" , ( ) => {
36
40
const lines = [
37
- ' # Header' ,
38
- '' ,
39
- ' Some text' ,
40
- '' ,
41
- ' ```md' ,
42
- ' Nested markdown content' ,
43
- ' ```javascript' ,
44
- ' function test() {' ,
45
- ' return true;' ,
46
- '}' ,
47
- ' ```' ,
48
- ' More nested markdown' ,
49
- ' ```' ,
50
- '' ,
51
- ' End of file'
41
+ " # Header" ,
42
+ "" ,
43
+ " Some text" ,
44
+ "" ,
45
+ " ```md" ,
46
+ " Nested markdown content" ,
47
+ " ```javascript" ,
48
+ " function test() {" ,
49
+ " return true;" ,
50
+ "}" ,
51
+ " ```" ,
52
+ " More nested markdown" ,
53
+ " ```" ,
54
+ "" ,
55
+ " End of file" ,
52
56
] ;
53
57
54
58
const stateTracker = new MarkdownBlockStateTracker ( lines ) ;
55
-
59
+
56
60
// First backtick closure is within nested block (not markdown end)
57
61
expect ( stateTracker . shouldStopAtPosition ( 10 ) ) . toBe ( false ) ;
58
-
62
+
59
63
// This is the backtick that closes the outer markdown block
60
64
expect ( stateTracker . shouldStopAtPosition ( 12 ) ) . toBe ( true ) ;
61
65
} ) ;
62
66
63
- test ( ' MarkdownBlockStateTracker handles simple code blocks correctly' , ( ) => {
67
+ test ( " MarkdownBlockStateTracker handles simple code blocks correctly" , ( ) => {
64
68
const lines = [
65
- ' Some code:' ,
66
- '' ,
67
- ' ```javascript' ,
68
- ' function test() {' ,
69
- ' return true;' ,
70
- '}' ,
71
- ' ```' ,
72
- '' ,
73
- ' More text'
69
+ " Some code:" ,
70
+ "" ,
71
+ " ```javascript" ,
72
+ " function test() {" ,
73
+ " return true;" ,
74
+ "}" ,
75
+ " ```" ,
76
+ "" ,
77
+ " More text" ,
74
78
] ;
75
79
76
80
const stateTracker = new MarkdownBlockStateTracker ( lines ) ;
77
-
81
+
78
82
// This is just a simple code block, not nested markdown
79
83
expect ( stateTracker . shouldStopAtPosition ( 6 ) ) . toBe ( false ) ;
80
- } ) ;
84
+ } ) ;
0 commit comments