File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 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;
5353
5454export function validateMarkdown ( md : string ) : boolean {
5555 // 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 ( ) ;
5758
5859 let valid = true ;
5960
6061 for ( const v of validations ) {
6162 if ( ! v . validate ( text ) ) {
6263 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+ }
6667 }
6768 }
6869
Original file line number Diff line number Diff line change @@ -132,4 +132,26 @@ Should not be an issue
132132First Step` ;
133133 expect ( validateMarkdown ( md ) ) . toBe ( true ) ;
134134 } ) ;
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+ } ) ;
135157} ) ;
You can’t perform that action at this time.
0 commit comments