Delete multiple Em Spaces not working when called outside InDesign
Hello! , I'm having an issue with a particular grep expression that doesn't seem to work when I try to execute via an external call, but id does work fine whenever I execute inside InDesign.
My script aims to delete multiple em spaces and replaces them with a normal space.
function deleteDoubleEmSpaces() {
//var doc = app.activeDocument;
var doc = app.documents.itemByID(iddoc);
findChangeGrep("~>{2,}"," ","","","","");
}
function findChangeGrep(findWhat, changeTo, findStyle, changeStyle, findChrStyle, changeChrStyle) {
var doc = app.documents.itemByID(iddoc);
//var doc = app.activeDocument;
try {
app.findGrepPreferences.findWhat = findWhat;
app.changeGrepPreferences.changeTo = changeTo;
if (findStyle) app.findGrepPreferences.appliedParagraphStyle = findStyle;
if (changeStyle) app.changeGrepPreferences.appliedParagraphStyle = changeStyle;
doc.changeGrep();
} catch (e) {}
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
}
If I run this via the script console from InDesign, it works ok. The regex seems to work fine in the find and change menu. I have other scripts that are called in the same way, and work fine.
Also, I have used this findChangeGrep() with a simplified grep, and also works.
My guess is that I have to call the em spaces different, but I can't find how. I have tried things like \\~\\>{2,} ; \\~>{2, }, but nothing seems to works.
The execution of this script is being made via C# , with a indd.DoScript() method, where indd is an instance of my Indesign App.
Any clues on where is the mistake? Thanks!
