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
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 62 63 64 65 66 67 |
#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