Strip Internal Linked Brackets

I am assuming this is possible with some more advanced JavaScript than my own skills. I’d love to add to an action to strip the internal linked brackets (e.g., [[remove the brackets around this]]) within an action.

Any guidance would be great! Thanks so much.

Try this code. It uses a regular expression pattern to replace each instance of text with double brackets around it with just the bracketed text, throughout the current draft content, and then update the current draft with the result.

draft.content = draft.content.replace(/\[\[(.*)\]\]/g, "$1");
draft.update();

Add it to a script step and check that it is sufficient for your uses.

If you want a backup, add draft.saveVersion(); before the previous two lines of code to crate a backup in the draft’s versions.

Hope that helps.

1 Like