[英]InDesign Endnote Automation
我正在使用這個簡單的腳本來獲取包裹在[ENDNOTE][/ENDNOTE]
標簽中的文本,並將它們變成實際的 InDesign 尾注。 我遇到的問題是只有前 4 個字符被放置在尾注標記之間(見下面的截圖),知道為什么會發生這種情況,或者如何使它正常工作?
var doc = app.activeDocument;
function footnoteToEndnotes () {
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '\\[ENDNOTE\\](.+?)\\[\\/ENDNOTE\\]';
var endnote,
fnotes = doc.findGrep();
for (var i = fnotes.length-1; i >= 0; i--) {
var taggedText = fnotes[i].contents.replace('[ENDNOTE]', '').replace('[/ENDNOTE]', '');
endnote = fnotes[i].insertionPoints[0].createEndnote();
endnote.texts[0].contents = taggedText;
fnotes[i].remove();
}
}
if (parseInt (app.version) < 13) {
alert ('This script requires InDesign CC2018 or later');
exit();
}
doc.endnoteOptions.frameCreateOption = EndnoteFrameCreate.NEW_PAGE;
footnoteToEndnotes();
因此,當我設置insertionPoints[0]
的內容時,完整的尾注最終出現在尾注標記內。 但是,在字符串的末尾有一個多余的制表符......我把它去掉了,它像我想要的那樣工作!
我替換了這一行:
endnote.texts[0].contents = taggedText;
用這些:
endnote.texts[0].insertionPoints[0].contents = taggedText;
endnote.texts[0].contents = endnote.texts[0].contents.replace('\t', '');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.