imdone-core 1.53.13 → 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.
|
@@ -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()
|
|
@@ -962,7 +968,7 @@ File.prototype.extractTaskWithDescription = function ({
|
|
|
962
968
|
)
|
|
963
969
|
|
|
964
970
|
task.init()
|
|
965
|
-
task.updateOrderMeta(config, task.format(task.descriptionString))
|
|
971
|
+
if (!config.keepEmptyPriority) task.updateOrderMeta(config, task.format(task.descriptionString))
|
|
966
972
|
task.orderModified = task.order + "" !== order + "" && !bothAreUndefNull(task.order, order)
|
|
967
973
|
|
|
968
974
|
return task
|
|
@@ -1348,4 +1354,28 @@ File.prototype.isWithinCodeSpanOrBlock = function(pos, content) {
|
|
|
1348
1354
|
return Task.isResultInMarkdownCode(positions, pos)
|
|
1349
1355
|
}
|
|
1350
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
|
+
|
|
1351
1381
|
module.exports = File
|