![](/img/trans.png)
[英]How to change color swatch of colored greyscale pictures using ExtendScript in InDesign?
[英]How can I remove italic and bold styling from all footnote references in an InDesign document using ExtendScript?
我正在嘗試使用ExtendScript從InDesign文檔的腳注引用中刪除粗體和斜體樣式。 腳注指的是正文中出現的少量數字。 就是說,我想從那個小數字中刪除斜體和粗體,而不是從實際腳注中刪除。 這是我的嘗試。 它與我想要的完全相反,意味着它從斜體和粗體中刪除了實際的腳注,但並未刪除正文中的小數字。
var document = app.activeDocument,
stories = document.stories,
nbStories = stories.length,
story,
footnotes,
nbFootnotes,
footnote,
texts,
nbTexts,
text,
i,
j,
k;
for (i = 0; i < nbStories; i += 1) {
story = stories[i];
footnotes = story.footnotes;
nbFootnotes = footnotes.length;
for (j = 0; j < nbFootnotes; j += 1) {
footnote = footnotes[j];
texts = footnote.texts;
nbTexts = texts.length;
for (k = 0; k < nbTexts; k += 1) {
text = texts[k];
text.fontStyle = "Regular";
}
}
}
我怎么能做到相反呢? (即,只刪除正文中的少量數字,而不去除實際腳注)
我可能不建議您遍歷所有故事,而建議您通過腳本使用GREP。 腳注標記模式為“〜F”。 這將同時捕獲文本標記和底部標題中的thos。 要專門針對文本腳注標記,您可以重新排列模式以僅考慮跟隨任何字符的標記。 完成此操作后,您將獲得一個腳注標記數組,可以在其上調用changeGrep以使您的標記風格化。 您必須設置“注釋”字符樣式才能使此代碼段正常工作。
function editFootNotesMarkers()
{var allresults,result,doc,characterStyle;
if ( !app.documents.length){ return; }
doc = app.activeDocument;
characterStyle = doc.characterStyles.itemByName ("note");
if ( !characterStyle.isValid){ return; }
app.findGrepPreferences.findWhat = "(?<=.)~F";
app.changeGrepPreferences.appliedCharacterStyle = characterStyle;
doc.changeGrep();
alert('done');
}
editFootNotesMarkers();
當然,無需任何腳本就可以實現;)
洛伊奇
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.