Because it’s Friday and I can’t concentrate on anything genuinely productive, I’ve been playing around with scripts and themes. Below are the theme tweak + script to turn this
into this
When I looked through the documentation, I didn’t see a way to call on what’s in parentheses in the theme, so what the script does is replace anything tagged with @due(today’s date) with @dueToday and anything tagged with @due(tomorrow’s date) to @dueTomorrow. It also adds a @today tag to all of them. The logic being I use the @today tag to look at everything I want to work on today, regardless of when it’s due (or if there’s no due date). The @dueToday and @dueTomorrow tags are just there to highlight items with looming deadlines.
function TaskPaperContextScript(editor, options) {
var today = DateTime.format('today');
var outline = editor.outline;
outline.groupUndoAndChanges(function () {
outline.evaluateItemPath('//@due = [d] today')
.forEach(function (each) {
each.setAttribute('data-dueToday', '');
each.setAttribute('data-today','');
each.removeAttribute('data-due');
});
});
outline.evaluateItemPath('//@due = [d] tomorrow')
.forEach(function (each) {
each.setAttribute('data-dueTomorrow', '');
each.setAttribute('data-today','');
each.removeAttribute('data-due');
});
}
Application("TaskPaper")
.documents[0].evaluate({
script: TaskPaperContextScript.toString()
})
If you don’t want the extra @today, just remove the two instances of each.setAttribute('data-today','');
In the theme.less file, add the following bits of code to get the colors (or change however you want to get your own formatting).
item[data-dueToday] {
color: red;
font-weight: bold;
}
item[data-dueTomorrow] {
color: rgb(79, 179, 209);
font-weight: bold;
}
Thanks to @jessegrosjean and @complexpoint for putting together the scripts I based this on and answering questions. They’ve made Javascript a lot less intimidating to look at.