File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
public/js/lib/editor/markdown-lint Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -7,30 +7,32 @@ import './lint.css'
77( function ( mod ) {
88 mod ( CodeMirror ) ;
99} ) ( function ( CodeMirror ) {
10- function validator ( text , options ) {
10+ function validator ( text ) {
1111 return lint ( text ) . map ( error => {
12- const lineNumber = error . lineNumber - 1
12+ const {
13+ ruleNames,
14+ ruleDescription,
15+ lineNumber : ln ,
16+ errorRange
17+ } = error
18+ const lineNumber = ln - 1
1319
14- let start , end
15- if ( error . errorRange ) {
16- start = error . errorRange [ 0 ] - 1
17- end = error . errorRange [ 1 ] - 1
18- } else {
19- start = 0
20- end = - 1
20+ let start = 0 , end = - 1
21+ if ( errorRange ) {
22+ [ start , end ] = errorRange . map ( r => r - 1 )
2123 }
2224
2325 return {
24- messageHTML : `${ error . ruleNames . join ( '/' ) } : ${ error . ruleDescription } ` ,
26+ messageHTML : `${ ruleNames . join ( '/' ) } : ${ ruleDescription } ` ,
2527 severity : 'error' ,
2628 from : CodeMirror . Pos ( lineNumber , start ) ,
2729 to : CodeMirror . Pos ( lineNumber , end )
2830 }
2931 } )
3032 }
3133
32- CodeMirror . registerHelper ( 'lint' , 'markdown' , validator ) ;
33- } ) ;
34+ CodeMirror . registerHelper ( 'lint' , 'markdown' , validator )
35+ } )
3436
3537function lint ( content ) {
3638 const { content : errors } = markdownlint . sync ( {
You can’t perform that action at this time.
0 commit comments