1 | var DEFAULT_TAGS = ['todo', 'fixme'];
|
2 |
|
3 | function getRegex(customTags) {
|
4 | var tags = DEFAULT_TAGS;
|
5 | if (customTags && customTags.length) {
|
6 | tags = tags.concat(customTags);
|
7 | }
|
8 |
|
9 | return (
|
10 |
|
11 | '\\s*' +
|
12 |
|
13 | '@?' +
|
14 |
|
15 | '(' + tags.join('|') + ')' +
|
16 |
|
17 | '\\s*' +
|
18 |
|
19 | '(?:\\(([^)]*)\\))?' +
|
20 |
|
21 | '\\s*' +
|
22 |
|
23 | ':?' +
|
24 |
|
25 | '\\s*' +
|
26 |
|
27 | '(.*?)' +
|
28 |
|
29 | '(?:\\s+/([^\\s]+)\\s*)?'
|
30 | );
|
31 | }
|
32 |
|
33 | function prepareComment(match, line, file) {
|
34 |
|
35 | if (!match || !match[1]) {
|
36 | return null;
|
37 | }
|
38 | var ref = match[2] || match[4] || '';
|
39 | var text = match[3] || '';
|
40 | return {
|
41 | file: file || 'unknown file',
|
42 | kind: match[1].toUpperCase(),
|
43 | line: line,
|
44 | text: text.trim(),
|
45 | ref: ref.trim()
|
46 | };
|
47 | }
|
48 |
|
49 | exports.getRegex = getRegex;
|
50 | exports.prepareComment = prepareComment;
|