imdone-core 1.50.2 → 1.50.3
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.
- package/lib/repository.js +40 -10
- package/package.json +1 -1
package/lib/repository.js
CHANGED
|
@@ -1573,16 +1573,46 @@ Repository.deserialize = function (repo, cb) {
|
|
|
1573
1573
|
}
|
|
1574
1574
|
|
|
1575
1575
|
Repository.regexQuery = function (tasks, queryString) {
|
|
1576
|
-
return tasks
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1576
|
+
return tasks
|
|
1577
|
+
.map((task) => {
|
|
1578
|
+
const escapedQueryString = tools.escapeRegExp(queryString.trim());
|
|
1579
|
+
|
|
1580
|
+
// Regex to match occurrences not part of a URL and not already surrounded by `==`
|
|
1581
|
+
const regex = new RegExp(
|
|
1582
|
+
`(?<!https?:\\/\\/[^\\s]*?)\\b${escapedQueryString}\\b(?![^\\s]*\\/)(?<!==)(?!==)`,
|
|
1583
|
+
'gi'
|
|
1584
|
+
);
|
|
1585
|
+
|
|
1586
|
+
// Regex to detect Markdown links `[title](url)` where `queryString` is in title or URL
|
|
1587
|
+
const markdownLinkRegex = new RegExp(
|
|
1588
|
+
`\\[([^\\]]*${escapedQueryString}[^\\]]*)\\]\\(([^)]+${escapedQueryString}[^)]*)\\)`,
|
|
1589
|
+
'gi'
|
|
1590
|
+
);
|
|
1591
|
+
|
|
1592
|
+
let match = task.content.match(regex) || task.content.match(markdownLinkRegex);
|
|
1593
|
+
task.match = match;
|
|
1594
|
+
|
|
1595
|
+
if (match && queryString.trim() && task.interpretedContent) {
|
|
1596
|
+
// Replace standalone occurrences
|
|
1597
|
+
task.interpretedContent = task.interpretedContent.replace(
|
|
1598
|
+
regex,
|
|
1599
|
+
'==$&=='
|
|
1600
|
+
);
|
|
1601
|
+
|
|
1602
|
+
// Replace Markdown links where queryString is in title or URL
|
|
1603
|
+
task.interpretedContent = task.interpretedContent.replace(
|
|
1604
|
+
markdownLinkRegex,
|
|
1605
|
+
(match) => `==${match}==`
|
|
1606
|
+
);
|
|
1607
|
+
|
|
1608
|
+
task.updateDescriptionData();
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
return task;
|
|
1612
|
+
})
|
|
1613
|
+
.filter(({ match }) => match);
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1586
1616
|
|
|
1587
1617
|
Repository.parseSortFromQueryString = function (queryString) {
|
|
1588
1618
|
const sort = []
|