imdone-core 1.53.12 → 1.53.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36,9 +36,9 @@ module.exports = class ReadStreamCodeParser extends ReadStreamTaskParser {
|
|
|
36
36
|
Object.keys(comments).forEach((comment) => {
|
|
37
37
|
const { begin, end, content } = comments[comment];
|
|
38
38
|
const line = begin;
|
|
39
|
-
const lastLine = end; //
|
|
39
|
+
const lastLine = end; // TODO lastLine should not be - 1
|
|
40
40
|
// <!--
|
|
41
|
-
// order
|
|
41
|
+
// order:-140
|
|
42
42
|
// -->
|
|
43
43
|
const lines = content.split('\n');
|
|
44
44
|
|
|
@@ -74,13 +74,38 @@ function isCheckBoxTask (config, line, beforeText) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
function hasTaskInText(config, text, isCodeFile) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
77
|
+
const hashStyleRegex = new XRegExp(getHashStyleRegex(config.tokenPrefix));
|
|
78
|
+
const linkStyleRegex = new XRegExp(LINK_STYLE_REGEX);
|
|
79
|
+
|
|
80
|
+
const inlineCodeRe = /`[^`]*`/g;
|
|
81
|
+
|
|
82
|
+
// Function to check if a match is within inline code
|
|
83
|
+
function isWithinInlineCode(index) {
|
|
84
|
+
let match;
|
|
85
|
+
while ((match = inlineCodeRe.exec(text)) !== null) {
|
|
86
|
+
const isInCode = index >= match.index && index < match.index + match[0].length
|
|
87
|
+
if (isInCode) return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Check for code style tasks
|
|
93
|
+
if (isCodeFile && hasCodeStyleTask(config, text)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check for hash style tasks
|
|
98
|
+
let result;
|
|
99
|
+
if ((result = hashStyleRegex.exec(text)) !== null && !isWithinInlineCode(result.index)) {
|
|
100
|
+
return config.lists.find((list) => text.includes(`${config.tokenPrefix}${list.name}`));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Check for link style tasks
|
|
104
|
+
if ((result = linkStyleRegex.exec(text)) !== null && !isWithinInlineCode(result.index)) {
|
|
105
|
+
return config.lists.find((list) => text.includes(`${config.tokenPrefix}${list.name}`));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return false;
|
|
84
109
|
}
|
|
85
110
|
|
|
86
111
|
function isBeforeTextMarkdownList(beforeText) {
|
|
@@ -105,9 +130,21 @@ function isLineOutsideMarkdownList(line, beforeText) {
|
|
|
105
130
|
}
|
|
106
131
|
|
|
107
132
|
function hasCodeStyleTask(config, text) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
133
|
+
const codeStylePatternRe = new RegExp(CODE_STYLE_PATTERN);
|
|
134
|
+
let result = codeStylePatternRe.exec(text);
|
|
135
|
+
|
|
136
|
+
if (!result) return false;
|
|
137
|
+
|
|
138
|
+
// Check if the match is within inline code
|
|
139
|
+
const inlineCodeRe = /`[^`]*`/g;
|
|
140
|
+
let match;
|
|
141
|
+
while ((match = inlineCodeRe.exec(text)) !== null) {
|
|
142
|
+
if (result.index >= match.index && result.index < match.index + match[0].length) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return config.includeList(result[1]);
|
|
111
148
|
}
|
|
112
149
|
|
|
113
150
|
function getCardTagsTaskContent ({
|
|
@@ -226,7 +263,6 @@ function getTextFileTaskContent ({
|
|
|
226
263
|
const taskContentLines = []
|
|
227
264
|
|
|
228
265
|
let inCodeBlock = false
|
|
229
|
-
let inCodeSpan = false
|
|
230
266
|
|
|
231
267
|
for (let i = 1; i < lines.length; i++) {
|
|
232
268
|
let line = lines[i]
|
|
@@ -236,16 +272,8 @@ function getTextFileTaskContent ({
|
|
|
236
272
|
inCodeBlock = !inCodeBlock
|
|
237
273
|
}
|
|
238
274
|
|
|
239
|
-
// Check for markdown code spans
|
|
240
|
-
if (isMarkDownFile && line.includes('`')) {
|
|
241
|
-
const codeSpanMatches = line.match(/`+/g)
|
|
242
|
-
if (codeSpanMatches && codeSpanMatches.length % 2 !== 0) {
|
|
243
|
-
inCodeSpan = !inCodeSpan
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
275
|
// Only break if the task is not in a markdown code block or code span
|
|
248
|
-
if (!inCodeBlock &&
|
|
276
|
+
if (!inCodeBlock && hasTaskInText(config, line)) break
|
|
249
277
|
if (isCheckBoxTask(config, line, beforeText)) break
|
|
250
278
|
if (isTaskInList && isLineOutsideMarkdownList(line, beforeText)) break
|
|
251
279
|
if (isCustomCardTerminator(config, line)) break
|
package/lib/file.js
CHANGED
|
@@ -375,8 +375,10 @@ File.prototype.extractCodeStyleTasks = function (config, pos, content) {
|
|
|
375
375
|
File.prototype.extractHashStyleTasks = function (config, pos, content) {
|
|
376
376
|
var hashStyleRegex = getHashStyleRegex(config.tokenPrefix)
|
|
377
377
|
var lang = this.getLang()
|
|
378
|
+
const codePositions = this.getMarkdownCodePositions(content);
|
|
378
379
|
var result
|
|
379
380
|
while ((result = hashStyleRegex.exec(content)) !== null) {
|
|
381
|
+
if (this.isResultInMarkdownCode(codePositions, result.index)) continue;
|
|
380
382
|
var [rawTask, list, orderGroup, order, text] = result
|
|
381
383
|
if (!config.listExists(list)) continue
|
|
382
384
|
|
|
@@ -406,13 +408,15 @@ File.prototype.extractHashStyleTasks = function (config, pos, content) {
|
|
|
406
408
|
this.addTask(task)
|
|
407
409
|
this.emit('task.found', task)
|
|
408
410
|
}
|
|
409
|
-
}
|
|
411
|
+
};
|
|
410
412
|
|
|
411
413
|
File.prototype.extractLinkStyleTasks = function (config, pos, content) {
|
|
412
414
|
var self = this
|
|
413
415
|
var linkStyleRegex = new XRegExp(LINK_STYLE_REGEX)
|
|
416
|
+
const codePositions = this.getMarkdownCodePositions(content);
|
|
414
417
|
var result
|
|
415
418
|
while ((result = linkStyleRegex.exec(content)) !== null) {
|
|
419
|
+
if (this.isResultInMarkdownCode(codePositions, result.index)) continue;
|
|
416
420
|
let [match, before, rawTask, text, list, colon, order] = result
|
|
417
421
|
const beforeLength = before ? before.length : 0
|
|
418
422
|
const posInContent = result.index + pos + beforeLength
|
|
@@ -446,6 +450,7 @@ File.prototype.extractCheckboxTasks = function (config, pos, content) {
|
|
|
446
450
|
if (!this.isMarkDownFile()) return
|
|
447
451
|
if (!config.isAddCheckBoxTasks()) return
|
|
448
452
|
|
|
453
|
+
const codePositions = this.getMarkdownCodePositions(content);
|
|
449
454
|
const type = Task.Types[config.getNewCardSyntax()]
|
|
450
455
|
const checkStyleRegex = new RegExp(CHECK_STYLE_PATTERN)
|
|
451
456
|
let result
|
|
@@ -459,6 +464,7 @@ File.prototype.extractCheckboxTasks = function (config, pos, content) {
|
|
|
459
464
|
)
|
|
460
465
|
}
|
|
461
466
|
while ((result = checkStyleRegex.exec(content)) !== null) {
|
|
467
|
+
if (this.isResultInMarkdownCode(codePositions, result.index)) continue;
|
|
462
468
|
let [match, before, checked, text] = result
|
|
463
469
|
const list =
|
|
464
470
|
checked.trim() === 'x' ? config.getDoneList() : config.getDefaultList()
|
|
@@ -961,10 +967,9 @@ File.prototype.extractTaskWithDescription = function ({
|
|
|
961
967
|
this.project
|
|
962
968
|
)
|
|
963
969
|
|
|
964
|
-
task.updateOrderMeta(config)
|
|
965
|
-
|
|
966
|
-
task.orderModified = task.order + "" !== order + "" && !bothAreUndefNull(task.order, order)
|
|
967
970
|
task.init()
|
|
971
|
+
if (!config.keepEmptyPriority) task.updateOrderMeta(config, task.format(task.descriptionString))
|
|
972
|
+
task.orderModified = task.order + "" !== order + "" && !bothAreUndefNull(task.order, order)
|
|
968
973
|
|
|
969
974
|
return task
|
|
970
975
|
}
|
|
@@ -1349,4 +1354,28 @@ File.prototype.isWithinCodeSpanOrBlock = function(pos, content) {
|
|
|
1349
1354
|
return Task.isResultInMarkdownCode(positions, pos)
|
|
1350
1355
|
}
|
|
1351
1356
|
|
|
1357
|
+
File.prototype.getMarkdownCodePositions = function (text) {
|
|
1358
|
+
const positions = [];
|
|
1359
|
+
const codeBlockRe = /```[\s\S]*?```/g;
|
|
1360
|
+
const inlineCodeRe = /`[^`]*`/g;
|
|
1361
|
+
|
|
1362
|
+
let match;
|
|
1363
|
+
|
|
1364
|
+
// Find code blocks
|
|
1365
|
+
while ((match = codeBlockRe.exec(text)) !== null) {
|
|
1366
|
+
positions.push({ start: match.index, end: match.index + match[0].length });
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
// Find inline code spans
|
|
1370
|
+
while ((match = inlineCodeRe.exec(text)) !== null) {
|
|
1371
|
+
positions.push({ start: match.index, end: match.index + match[0].length });
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
return positions;
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
File.prototype.isResultInMarkdownCode = function (positions, index) {
|
|
1378
|
+
return positions.some(pos => index >= pos.start && index < pos.end);
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1352
1381
|
module.exports = File
|
|
@@ -3,6 +3,12 @@ const {getIsoDateWithOffset} = require('../adapters/date-time')
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const simpleTemplate = '\n<!--\ncreated:${timestamp}\n-->\n'
|
|
5
5
|
|
|
6
|
+
function flattenObject(object) {
|
|
7
|
+
return Object.keys(object).reduce((acc, key) => {
|
|
8
|
+
return { ...acc, [`template_${key}`]: object[key] };
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
module.exports = class DefaultBoardPropertiesPlugin extends Plugin {
|
|
7
13
|
constructor(project) {
|
|
8
14
|
super(project)
|
|
@@ -14,15 +20,18 @@ module.exports = class DefaultBoardPropertiesPlugin extends Plugin {
|
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
getBoardProperties() {
|
|
17
|
-
const
|
|
18
|
-
|
|
23
|
+
const templates = flattenObject(this.templates);
|
|
24
|
+
const clearFilterURL = this.getFilterURL('');
|
|
25
|
+
const getFilterURL = (filter) => this.getFilterURL(filter);
|
|
26
|
+
const getFilterLink = (filter) => `[Filter By: ${filter}](${this.getFilterURL(filter)})`;
|
|
27
|
+
|
|
19
28
|
return {
|
|
20
29
|
date: `${getIsoDateWithOffset(new Date()).substring(0, 10)}`,
|
|
21
30
|
timestamp: getIsoDateWithOffset(new Date()),
|
|
22
|
-
clearFilterURL
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
clearFilterURL,
|
|
32
|
+
getFilterURL,
|
|
33
|
+
getFilterLink,
|
|
34
|
+
...templates
|
|
26
35
|
}
|
|
27
36
|
}
|
|
28
37
|
|
package/lib/task.js
CHANGED
|
@@ -83,6 +83,10 @@ class Task {
|
|
|
83
83
|
get order() {
|
|
84
84
|
return this.innerOrder
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
get descriptionString() {
|
|
88
|
+
return this.description.join(lineEnd)
|
|
89
|
+
}
|
|
86
90
|
|
|
87
91
|
updateLastLine() {
|
|
88
92
|
this.lastLine = this.getLastLine()
|
|
@@ -135,10 +139,8 @@ class Task {
|
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
getTextAndDescription() {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
lineEnd
|
|
141
|
-
)}`.replace(/<!--\s*\[\s*([\s\S]*?)\s*\]\s*-->/gm, '$1')
|
|
142
|
+
const taskContent = `${this.markdownBeforeText}${this.text}${lineEnd}${this.descriptionString}`
|
|
143
|
+
.replace(/<!--\s*\[\s*([\s\S]*?)\s*\]\s*-->/gm, '$1')
|
|
142
144
|
return this.getText(
|
|
143
145
|
{
|
|
144
146
|
stripMeta: true,
|
|
@@ -150,11 +152,9 @@ class Task {
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
getRawTextAndDescription() {
|
|
153
|
-
const description = _clone(this.description)
|
|
154
155
|
const text = this.text
|
|
155
|
-
if (description.length < 1) return text
|
|
156
|
-
|
|
157
|
-
return `${text}${lineEnd}${descriptionMD}${lineEnd}`
|
|
156
|
+
if (this.description.length < 1) return text
|
|
157
|
+
return `${text}${lineEnd}${this.descriptionString}${lineEnd}`
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
getProgress() {
|
|
@@ -174,7 +174,7 @@ class Task {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
updateContent() {
|
|
177
|
-
this.content = this.text + lineEnd + this.
|
|
177
|
+
this.content = this.text + lineEnd + this.descriptionString
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
updateFromContent(content) {
|
|
@@ -434,7 +434,7 @@ Task.getMetaOrderRegex = function (config) {
|
|
|
434
434
|
)
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
Task.prototype.updateOrderMeta = function (config, descContent = this.
|
|
437
|
+
Task.prototype.updateOrderMeta = function (config, descContent = this.descriptionString) {
|
|
438
438
|
if (config.orderMeta) {
|
|
439
439
|
if (!isNumber(this.order)) return this.order = ''
|
|
440
440
|
const addNewLine = config.isMetaNewLine()
|