longform
longform copied to clipboard
Compile step request: search and replace
trafficstars
Search for a string and replace it with something else.
It would be nice to be able to add this step multiple times with different search and replace schemes.
that should already be doable with the current featureset. Compile Step simply replaces every instance of "a" with "💥". (If you know regex, you can also use .replace instead of .replaceAll.)
But a more accessible workflow that offers search/replace for non-coders might make a lot of sense, too.
module.exports = {
description: {
name: "Sample Script",
description: "Replaces every 'a' with an explosion emoji.",
availableKinds: ["Manuscript", "Scene"],
options: []
},
compile (input, context) {
input.contents = input.contents.replaceAll ("a", "💥");
return input;
}
};
I like the idea of formalizing this as a built-in step but leaving more complex versions to user steps. Good suggestion.