The TaskPaper 3 scripting interface gives direct support for increasing or decreasing the overall fold level of the document.
Here is one way of increasing the folding level. You can make a second copy and derive a decrease folding level script by editing the value of inc
from true to false in the withOptions
section.
(The script returns the resulting folding level as an integer, in case you want that for something like a Keyboard Maestro notification).
(function (dctOptions) {
'use strict';
function TaskPaperContext(editor, opt) {
return editor[
(opt.inc ? 'in' : 'de') + 'creaseExpansionLevel'
]() && editor.getExpansionLevel();
}
var ds = Application("TaskPaper")
.documents,
varResult = ds.length ? ds[0].evaluate({
script: TaskPaperContext.toString(),
withOptions: dctOptions
}) : undefined;
return varResult;
})({
inc: true // edit to true for 'increase'
});