Prism is another highlighter, which is designed to meet the modern standard.
To extend the functionality of Prism and to add a new language support for Prism are not difficult.
Here are examples of three different highlighters:
Prism
#targetengine "session"
main();
function main() {
StyleSetup();
myWorking();
myCleanup();
}
function StyleSetup() {
var myDocument;
if (app.documents.length == 0) {
myDocument = app.documents.add();
} else {
myDocument = app.documents.item(0);
}
myCompsiteFontsSetup(myDocument);
}
function myWorking() {
}
function myCleanup() {
}
// ===== Composite Fonts ==================================
function SetupOneCompFont(myDocument, nFName, nHanName, nHanStyle, nRomName, nRomStyle) {
var nCF = myDocument.compositeFonts.item(nFName);
try {
var myName = nCF.name;
}
catch (myError) {
nCF = myDocument.compositeFonts.add();
with (nCF) {
name = nFName;
var idx;
for (idx = 0; idx < 3; idx++) {
//console.log('Walking east one step');
with (compositeFontEntries.item(idx)) {
appliedFont = app.fonts.item(nHanName);//nHanName;
fontStyle = nHanStyle;
}
}
for (idx = 3; idx < 5; idx++) {
with (compositeFontEntries.item(idx)) {
appliedFont = app.fonts.item(nRomName); //nRomName;
fontStyle = nRomStyle;
}
}
}
}
}
function myCompsiteFontsSetup(myDocument) {
try {
SetupOneCompFont(myDocument, "明體 - Caribi", "文鼎明體", "Medium", "Calibri", "Regular");
}
catch (theError) {
}
try {
SetupOneCompFont(myDocument, "隸書 - Times", "文鼎隸書", "Bold", "Times New Roman", "Regular");
}
catch (theError2) {
}
}
Syntaxhighlighter
#targetengine "session" main(); function main() { StyleSetup(); myWorking(); myCleanup(); } function StyleSetup() { var myDocument; if (app.documents.length == 0) { myDocument = app.documents.add(); } else { myDocument = app.documents.item(0); } myCompsiteFontsSetup(myDocument); } function myWorking() { } function myCleanup() { } // ===== Composite Fonts ================================== function SetupOneCompFont(myDocument, nFName, nHanName, nHanStyle, nRomName, nRomStyle) { var nCF = myDocument.compositeFonts.item(nFName); try { var myName = nCF.name; } catch (myError) { nCF = myDocument.compositeFonts.add(); with (nCF) { name = nFName; var idx; for (idx = 0; idx < 3; idx++) { //console.log('Walking east one step'); with (compositeFontEntries.item(idx)) { appliedFont = app.fonts.item(nHanName);//nHanName; fontStyle = nHanStyle; } } for (idx = 3; idx < 5; idx++) { with (compositeFontEntries.item(idx)) { appliedFont = app.fonts.item(nRomName); //nRomName; fontStyle = nRomStyle; } } } } } function myCompsiteFontsSetup(myDocument) { try { SetupOneCompFont(myDocument, "明體 - Caribi", "文鼎明體", "Medium", "Calibri", "Regular"); } catch (theError) { } try { SetupOneCompFont(myDocument, "隸書 - Times", "文鼎隸書", "Bold", "Times New Roman", "Regular"); } catch (theError2) { } }
code prettifier
#targetengine "session" main(); function main() { StyleSetup(); myWorking(); myCleanup(); } function StyleSetup() { var myDocument; if (app.documents.length == 0) { myDocument = app.documents.add(); } else { myDocument = app.documents.item(0); } myCompsiteFontsSetup(myDocument); } function myWorking() { } function myCleanup() { } // ===== Composite Fonts ================================== function SetupOneCompFont(myDocument, nFName, nHanName, nHanStyle, nRomName, nRomStyle) { var nCF = myDocument.compositeFonts.item(nFName); try { var myName = nCF.name; } catch (myError) { nCF = myDocument.compositeFonts.add(); with (nCF) { name = nFName; var idx; for (idx = 0; idx < 3; idx++) { //console.log('Walking east one step'); with (compositeFontEntries.item(idx)) { appliedFont = app.fonts.item(nHanName);//nHanName; fontStyle = nHanStyle; } } for (idx = 3; idx < 5; idx++) { with (compositeFontEntries.item(idx)) { appliedFont = app.fonts.item(nRomName); //nRomName; fontStyle = nRomStyle; } } } } } function myCompsiteFontsSetup(myDocument) { try { SetupOneCompFont(myDocument, "明體 - Caribi", "文鼎明體", "Medium", "Calibri", "Regular"); } catch (theError) { } try { SetupOneCompFont(myDocument, "隸書 - Times", "文鼎隸書", "Bold", "Times New Roman", "Regular"); } catch (theError2) { } }
Comments