This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: This script:1. Opens /Dropbox/Task Management/Next Actions.taskpaper2. Removes any occurences of @start(YYYY-MM-DD) from this file, where YYYY-MM-DD is on or before today3. Folds all lines containing @start(YYYY-MM-DD), where YYYY-MM-DD is a future date

Another script of mine, "Custom Classes and Functions", must be installed for this to work.

Copyright (c) 2017 Duncan MacIntyre

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.

# the following code:# 1. gets a DateObject for today# 2. gets this date as a YYYY-MM-DD string# 3. removes the dashes# 4. stores this in the today variabletoday=datetime.date.today().isoformat().replace('-','')# create a NumTemplate object for dates in the format ' @start(YYYY-MM-DD)' where YYYY-MM-DD# is a date# (the NumTemplate class is defined in the "Custom Classes and Functions" workflow)date_template=NumTemplate(' @start\({}{}{}{}-{}{}-{}{}\)')# unfold all texteditor.unfold_all()# get the text of the current document, store this in the text variabletext=editor.get_text()# the following code:# 1. using NumTemplate.re_gen, forms a regular expression to match all occurences of # ' @start(YYYY-MM-DD)' where YYYY-MM-DD is a past or present date# 2. using re.sub(), removes matches to this re from text# 3. replaces all text in the current document with this, without scrollingeditor.replace_text(0,len(text),re.sub(date_template.re_gen('<'+today,'='+today),'',text),False)# the following code:# 1. using the gen method of the today object, forms a regular expression to match all occurences# of ' @start(YYYY-MM-DD)' where YYYY-MM-DD is a future date# 2. passes this on as outputworkflow.set_output(date_template.re_gen('>'+today))