imdone-core 1.43.7 → 1.44.1
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/file.js +24 -10
- package/lib/task.js +3 -3
- package/package.json +1 -1
package/lib/file.js
CHANGED
|
@@ -160,18 +160,30 @@ File.addCompleted = function ({ task, content, config }) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
File.parseDueDate = function (config, text) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
return File.parseDate(config, text, 'due')
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
File.parseRemindDate = function (config, text) {
|
|
167
|
+
return File.parseDate(config, text, 'remind')
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
File.parseDeferDate = function (config, text) {
|
|
171
|
+
return File.parseDate(config, text, 'defer')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
File.parseDate = function (config, text, dateType) {
|
|
175
|
+
if (text.includes(`${dateType}${config.getMetaSep()}`)) return text
|
|
176
|
+
let dateString
|
|
177
|
+
return text.replace(new RegExp(`(\\s${dateType})\\s.*?\\.`,'gi'), (match, p1) => {
|
|
178
|
+
if (dateString) return match
|
|
167
179
|
try {
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
170
|
-
|
|
171
|
-
return `${p1.toLowerCase()}${config.getMetaSep()}${
|
|
180
|
+
const date = chrono.parseDate(match, new Date(), {forwardDate: true})
|
|
181
|
+
if (!date) return match
|
|
182
|
+
dateString = getIsoDateWithOffset(date)
|
|
183
|
+
return `${p1.toLowerCase()}${config.getMetaSep()}${dateString}`
|
|
172
184
|
} catch (e) {
|
|
173
|
-
console.log(`Unable to parse
|
|
174
|
-
return
|
|
185
|
+
console.log(`Unable to parse ${dateType} date for ${text}`)
|
|
186
|
+
return match
|
|
175
187
|
}
|
|
176
188
|
})
|
|
177
189
|
}
|
|
@@ -263,6 +275,8 @@ File.prototype.transformTask = function ({config, modify, task}) {
|
|
|
263
275
|
})
|
|
264
276
|
content = trackListChanges.content
|
|
265
277
|
content = File.parseDueDate(config, content)
|
|
278
|
+
content = File.parseRemindDate(config, content)
|
|
279
|
+
content = File.parseDeferDate(config, content)
|
|
266
280
|
content = File.addCompleted({ task, content, config })
|
|
267
281
|
if (
|
|
268
282
|
content.trim() !== task.content.trim()
|
package/lib/task.js
CHANGED
|
@@ -26,7 +26,7 @@ const {
|
|
|
26
26
|
* @param {} obj
|
|
27
27
|
* @return
|
|
28
28
|
*/
|
|
29
|
-
const DATE_META_KEYS = ['due', 'created', 'remind', 'completed']
|
|
29
|
+
const DATE_META_KEYS = ['due', 'defer', 'created', 'remind', 'completed']
|
|
30
30
|
class Task {
|
|
31
31
|
constructor(config, obj, dontParse) {
|
|
32
32
|
if (!_isObject(obj)) throw new Error('obj must be an Object')
|
|
@@ -291,7 +291,7 @@ Task.MetaRegExp = new RegExp(
|
|
|
291
291
|
)
|
|
292
292
|
Task.getMetaRegExp = function (config) {
|
|
293
293
|
return new RegExp(
|
|
294
|
-
`(^|\\s)([a-zA-Z-_]+?)${config.getMetaSep()}(
|
|
294
|
+
`(^|\\s)([a-zA-Z-_]+?)${config.getMetaSep()}(?![*_]+)(?!\\/\\/)([${
|
|
295
295
|
Task.AnyLanguageGroup
|
|
296
296
|
}${Task.EmojiGroup}]+)`,
|
|
297
297
|
'gu'
|
|
@@ -299,7 +299,7 @@ Task.getMetaRegExp = function (config) {
|
|
|
299
299
|
}
|
|
300
300
|
Task.getMetaRegExpQuotes = function (config) {
|
|
301
301
|
return new RegExp(
|
|
302
|
-
`(^|\\s)([a-zA-Z-_]+?)${config.getMetaSep()}(
|
|
302
|
+
`(^|\\s)([a-zA-Z-_]+?)${config.getMetaSep()}(?![*_]+)"((?${config.getMetaSep()}""|[^"]|[${
|
|
303
303
|
Task.AnyLanguageGroup
|
|
304
304
|
}${Task.EmojiGroup}])*)"`,
|
|
305
305
|
'gu'
|