File tree 2 files changed +27
-4
lines changed
2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -53,16 +53,17 @@ const codeBlockRegex = /```[a-z]*\n[\s\S]*?\n```/gm;
53
53
54
54
export function validateMarkdown ( md : string ) : boolean {
55
55
// remove codeblocks which might contain any valid combinations
56
- const text = md . replace ( codeBlockRegex , "" ) ;
56
+ // trim white space
57
+ const text = md . replace ( codeBlockRegex , "" ) . trim ( ) ;
57
58
58
59
let valid = true ;
59
60
60
61
for ( const v of validations ) {
61
62
if ( ! v . validate ( text ) ) {
62
63
valid = false ;
63
- // if (process.env.NODE_ENV !== "test") {
64
- console . warn ( v . message ) ;
65
- // }
64
+ if ( process . env . NODE_ENV !== "test" ) {
65
+ console . warn ( v . message ) ;
66
+ }
66
67
}
67
68
}
68
69
Original file line number Diff line number Diff line change @@ -132,4 +132,26 @@ Should not be an issue
132
132
First Step` ;
133
133
expect ( validateMarkdown ( md ) ) . toBe ( true ) ;
134
134
} ) ;
135
+ it ( "should ignore empty space at the top" , ( ) => {
136
+ const md = `
137
+
138
+ # Title
139
+
140
+ Description.` ;
141
+ expect ( validateMarkdown ( md ) ) . toBe ( true ) ;
142
+ } ) ;
143
+ it ( "should ignore empty space at the bottom" , ( ) => {
144
+ const md = `
145
+
146
+ # Title
147
+
148
+ Description.
149
+
150
+
151
+
152
+
153
+
154
+ ` ;
155
+ expect ( validateMarkdown ( md ) ) . toBe ( true ) ;
156
+ } ) ;
135
157
} ) ;
You can’t perform that action at this time.
0 commit comments