omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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?

    Editorial
    3
    8
    5367
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LERS
      LERS last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        Based on your final objective, there are currently two ways you could do this:

        Option A:

        1. 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
          ...
          
        2. Pass those ranges/lines to a Repeat... block ("Every Line") and turn on the "Reverse" option (important!)

        3. 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.

        1. 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)

        2. Then use a Fold Lines Containing... action with a variable as the regex pattern.

        1 Reply Last reply Reply Quote 0
        • LERS
          LERS last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • LERS
            LERS last edited by

            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

            1 Reply Last reply Reply Quote 0
            • Macmanuk
              Macmanuk last edited by

              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?

              1 Reply Last reply Reply Quote 0
              • omz
                omz last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • LERS
                  LERS last edited by

                  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

                  1 Reply Last reply Reply Quote 0
                  • Macmanuk
                    Macmanuk last edited by

                    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.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB Forums | Contributors