forked from GitBruno/Novelty
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReverse_Quotation.jsx
More file actions
executable file
·61 lines (49 loc) · 2.01 KB
/
Reverse_Quotation.jsx
File metadata and controls
executable file
·61 lines (49 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
ReverseQuotation.jsx
An InDesign CS3/4 JavaScript
Bruno Herfst 2010
This script turns American style quotations:
He said, “Didn’t you like ‘That ’70s Show’ back then?”
into European style quotations:
He said, ‘Didn’t you like “That ’70s Show” back then?’
(and back again :)
*** Please note it will not pick-up words ending with an apostrophe ***
‘It will pick up the students’ apostrophes as closing quotation marks’ (Oops)
‘But it will leave students’s apostrophes’ (OK!)
*/
#target indesign;
main();
function main(){
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if(app.documents.length != 0){
if (app.activeDocument.stories.length != 0){
myDoc = app.activeDocument;
ReverseQuotation(myDoc);
}
else{
alert("The document does not contain any text. Please open a document containing text and try again.");
}
}
else{
alert("No documents are open. Please open a document and try again.");
}
}
function ReverseQuotation(myDoc){
var findChars = new Array("~](?=[A-Z,a-z,0-9])","~[","~]","~{","~}","<singleQuoteLeft>","<singleQuoteRight>","<DoubleQuoteLeft>","<DoubleQuoteRight>","<StaySingle>");
var replaceChars = new Array("<StaySingle>","<singleQuoteLeft>","<singleQuoteRight>","<DoubleQuoteLeft>","<DoubleQuoteRight>","~{","~}","~[","~]","~]");
app.findChangeGrepOptions.includeFootnotes = true;
app.findChangeGrepOptions.includeHiddenLayers = true;
app.findChangeGrepOptions.includeLockedLayersForFind = true;
app.findChangeGrepOptions.includeLockedStoriesForFind = true;
app.findChangeGrepOptions.includeMasterPages = true;
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
for(var i=0; i < findChars.length; i++){
var findChar = findChars[i];
var replaceChar = replaceChars[i];
app.findGrepPreferences.findWhat = findChar;
app.changeGrepPreferences.changeTo = replaceChar;
myDoc.changeGrep();
}
}