Find multiple lines of text, cut move then append

I’m interested in an action that can find any text that starts and ends with “{>> <<}”

I’d like to cut or move this text to the bottom of the same draft.

I’ve seen similar on the community but can’t locate precisely this.

Example of original text looks like this:


# Header 

Some text

Some more text. 

{>>Some text in between.<<} 

Some text. 

{>>Some more text in between.<<}
{>>Some more text in between again that is quite long and goes on for a few lines but is all contained inside of the curly arrow braces.<<} 

Some text. 

Example of desired output:


# Header 

Some text

Some more text. 

Some text. 

Some text. 

---

{>>Some text in between.<<} 

{>>Some more text in between.<<}
{>>Some more text in between again that is quite long and goes on for a few lines but is all contained inside of the curly arrow braces.<<} 

I suspect you have seen similar in terms of moving completed tasks to the end of a draft.

You should be able to tweak the following action to search for your preferred marker pair rather than the completed task syntax.

However, there is one caveat. in your example above you have a blank line between the first match and the second and third matches. Presumably this is because the second and third matches are sequential.

As a result, to exactly match the behaviour you describe, I would recommend that when you match the current line and check it, you also check if the next line is also a match. If it is not, add an extra newline to your output. If it is a match, add nothing.

3 Likes

@sylumer Thank you for pointing me in the right direction… will circle back if I have any questions.

With appreciation!

1 Like

Wondering if we can build on this action to make it more valuable?

PART 1:

I’d like to add a footnote to each commented line moved down to the bottom of the page.

The structure of the text would be as follows:

{>>Some text strings here commented out and moved down<<}
New text is always on the next line. No line break.

{>>Sometimes text runs long, really really really really long - several lines worth. Sometimes text runs long, really really really really long - several lines worth. Sometimes text runs long, really really really really long - several lines worth. Sometimes text runs long, really really really really long - several lines worth.<<}
Then the new text below.

{>>Occasionally, there is an orfan line that is commented out with no text following.<<}

{>>One more to keep the numbering<<}
One more.

The result would be:

New text is always on the next line. No line break. [^1]:

Then the new text below. [^2]:

One more. [^3]:


“## Footnotes”

[^1]: {>>Some text strings here commented out and moved down<<}
[^2]: {>>Sometimes text runs long, really really really really long - several lines worth. Sometimes text runs long, really really really really long - several lines worth. Sometimes text runs long, really really really really long - several lines worth. Sometimes text runs long, really really really really long - several lines worth.<<}
{>>Occasionally, there is an organ line that is commented out with no text following.<<}
[^3]: {>>One more to keep the numbering<<}

PART 2:

The use case for the above is to extract the text from the “upper” results (Draft title to above the separating line indicating “Footnotes.”)

From this results I’d like to copy the text while removing the footnote marker “[^1]:” from the end of each line. I can only see this as a separate action, albeit part of this larger project.

I’d copy the “results” text and create a Draft for the footnote marker to be stripped, leaving the original work intact.

This would allow me to use the text outside of Drafts in a fluid manner.

Not sure if any of this is possible… grateful for the assistance.

1 Like