A Find/Replace "Step" for Custom Actions (with RegEx)


#21

Here you go: https://actions.getdrafts.com/a/1Fu


#22

I think this might be the sort of thing you are after.

// define regex to use...
//Drop the double quotes from the original and add a space after page
const findRegex = /\[page /g;
// define replacement expression...
const replaceWith = "#@";

// do the replacement ...
draft.content = draft.content.replace(findRegex, replaceWith);

//Do some more replacements...
draft.content = draft.content.replace(/^highlight #@/gm, "#@");
draft.content = draft.content.replace(/(#@[0-9]+)]: /g, "$1\n");

//Update the draft
draft.update;

Hope that helps.


#23

This is great - thank you both for your help with this!


#24

Great - thanks for sharing!


#25

Just as an addendum, please also write Readdle and ask them to offer better export options for annotations, including turning off or modifying the “highlight” text, and offering direct export to Drafts rather than having to copy and paste from an email draft… I’ve done this before but they don’t seem to think enough people care about it to bother changing anything.


#26

Will do - It’s really astonishing that there isn’t a more flexible way of dealing with annotations.