diff --git a/README.md b/README.md index c74429cf..5397a3ff 100644 --- a/README.md +++ b/README.md @@ -524,7 +524,7 @@ You can also include and exclude folders from the tree using the context menu. T When the extension was first written, very basic markdown support was added simply by adding a pattern to the default regex to match "`- [ ]`". A better way to handle markdown TODOs is to add "`(-|\d+.)`" to the list of "comments" in the first part of the regex and then adding "`[ ]`" and "`[x]`" to the list of tags in `settings.json`, e.g. : ```json -"todo-tree.regex.regex": "(//|#|", + "", + "" + ].join( "\n" ); + + var matches = Array.from( sample.matchAll( regex ) ); + var lines = sample.split( "\n" ); + var lineNumbers = matches.map( function( match ) + { + var uptoMatch = sample.slice( 0, match.index ); + return uptoMatch.split( "\n" ).length - 1; + } ); + var matchedLines = lineNumbers.map( function( lineNumber ) + { + return lines[ lineNumber ]; + } ); + + assert.equal( matches.length, 4, "every actual TODO occurrence should still be detected" ); + assert.equal( lineNumbers.indexOf( 3 ), -1, "regex should not report TODOs starting on a bare HTML opener line" ); + assert.deepEqual( lineNumbers, [ 0, 1, 4, 5 ], "default regex should only match TODO tags on their own lines" ); + assert.deepEqual( matchedLines, + [ + "TODO case 1 Shows up normally", + "", + "TODO case 3 NOT Preceded by extra TODO after multi-line HTML comment", + "TODO case 4 Shows up normally" + ], + "default regex should only match TODO text which shares its line" ); +} ); + QUnit.test( "utils.isIncluded returns true when no includes or excludes are specified", function( assert ) { assert.ok( utils.isIncluded( "filename.js", [], [] ) === true );