cdocparser
Advanced tools
Comparing version 0.12.0 to 0.12.1
11
index.js
@@ -54,3 +54,3 @@ 'use strict'; | ||
escapeStringRegexp(blockCommentStyle) + | ||
'((?:[^*]|[\\r\\n]|(?:\\*+(?:[^*/]|[\\r\\n])))*)(\\*+)\\/'; | ||
'((?:[^*]|\\n|(?:\\*+(?:[^*/]|\\n)))*)(\\*+)\\/'; | ||
} | ||
@@ -110,3 +110,3 @@ | ||
var cleanBlockComment = function (comment) { | ||
var removeFirstLine = comment.replace(/^.*?[\r\n]+|[\r\n].*?$/g, ''); | ||
var removeFirstLine = comment.replace(/^.*?\n+|\n.*?$/g, ''); | ||
var removeLeadingStar = removeFirstLine.replace(/^[ \t]*\*/gm, ''); | ||
@@ -137,2 +137,7 @@ return stripIndent(removeLeadingStar).split(/\n/); | ||
var unifyLineEndings = function (code) { | ||
return code.replace(/\r\n?|\n/g, '\n'); | ||
}; | ||
function CommentExtractor (parseContext, opts) { | ||
@@ -171,2 +176,4 @@ this.parseContext = parseContext; | ||
CommentExtractor.prototype.extract = function (code) { | ||
code = unifyLineEndings(code); | ||
var match; | ||
@@ -173,0 +180,0 @@ var comments = []; |
{ | ||
"name": "cdocparser", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"description": "Extract C style comments and extract context from source", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "mocha test" | ||
"test": "./node_modules/mocha/bin/mocha test" | ||
}, | ||
@@ -26,3 +26,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"assert": "^1.1.1" | ||
"assert": "^1.1.1", | ||
"mocha": "^2.1.0" | ||
}, | ||
@@ -29,0 +30,0 @@ "dependencies": { |
@@ -230,2 +230,6 @@ CDocParser | ||
#### 0.12.1 | ||
* Unify platform specify line breaks (like `\r\n`) to `\n` before processing | ||
#### 0.12.0 | ||
@@ -232,0 +236,0 @@ |
@@ -504,2 +504,20 @@ var fs = require('fs'); | ||
describe('File with CRLF', function(){ | ||
it('should extract comments', function (){ | ||
var comments = getCommentsFrom('crlf.test.scss'); | ||
assert.equal(comments.length, 2); | ||
assert.deepEqual(comments[0].lines, [ | ||
'Block comment with CRLF.', | ||
'With multiple lines.' | ||
]); | ||
assert.deepEqual(comments[0].commentRange, { start: 1, end: 4 }); | ||
assert.deepEqual(comments[1].lines, [ | ||
'', | ||
'Comment with CRLF.', | ||
'It have multiple lines in a single comment.', | ||
'' | ||
]); | ||
assert.deepEqual(comments[1].commentRange, { start: 6, end: 9 }); | ||
}); | ||
}); | ||
@@ -506,0 +524,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41932
21
840
332
2