Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Any way of folding lines based on a Python script?
-
The folding lines action in the latest beta version is great. However, it's limited to folding lines based on a Regular Expression. Is there a way of using this action based on a Python script?. My final objective is to be able to fold lines based due dates in a Taskpaper file containing tags in the form
@due(YYYY-MM-DD)
.Thanks!
-
Based on your final objective, there are currently two ways you could do this:
Option A:
-
Determine the character ranges you want to fold in a Python script somehow. Then set the output of the script action to the ranges, one per line, for example something like:
0:10 45:55 101:123 ...
-
Pass those ranges/lines to a Repeat... block ("Every Line") and turn on the "Reverse" option (important!)
-
Put a Fold Text action inside the Repeat block, select "Range of Text" and put the Repeat: Text variable into the "from:to" field.
Option B:
This is a bit unconventional, but might be easier for your kind of use case.
-
Use the Python script to construct a regular expression dynamically, based on the due dates that actually exist in your document. The result might look like
@due\(2015-05-10|2015-05-11|2015-06-01)
-
Then use a Fold Lines Containing... action with a variable as the regex pattern.
-
-
Thanks so much for your detailed comments. Actually, I started working on something similar to what you described in Option B before reading your response.
Regards.
-
Ole, this is just to let you know that I have the Workflow up and running in case you want to check it out. I haven't made it public because is a Beta feature.
Thanks again,
LERS
-
Hi LERS is there any chance of seeing the script or workflow as I've wanted to do the same but haven't had the time to work it out (or the skills).
Perhaps you could post the link to this forum if ok with omz?
-
Great! You can of course post a link here, I would just ask that you keep beta workflows unlisted (i.e. turn off the "public" switch when sharing) to avoid confusion in the main workflow directory.
-
Ole,
Thanks for the quick response, I wasn't sure if I was supposed to post links to Workflows using beta actions (even unlisted ones).
Macmanuk,
No problem, here is the unlisted link.
Let me know if you have questions. I might tweak it a little bit more. If so, I'll upload it to the same address.
LERS
-
Thanks LERS and omz for your prompt replies. The workflow is great and has really enhanced my used of editorial.
I look forward to hacking it further now I have a template to understand.
Thanks again.