🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
4 messages
4 total messages Started by Dave_Saunders Mon, 02 Feb 2009 12:58
Script Poster
#1658
Author: Dave_Saunders
Date: Mon, 02 Feb 2009 12:58
39 lines
1759 bytes
We used to have a topic that held a script for posting scripts here, but it must have scrolled off into the ether. Here's the script I use. You can see that it was written by "Peter" -- that's Peter Kahrel, who had posted it here in that previous topic.

Just select your script and then run this script -- it's for either CS3 or CS4.

//DESCRIPTION: Peter's script poster

with( app.documents.add() )  
   {  
   textPreferences.typographersQuotes = false;  
   with( app.activeDocument.textFrames.add() )  
      {  
      geometricBounds = [0,0,'700pt','500pt'];  
      insertionPoints[0].select();  
      }  
   }  
app.paste();  
app.findTextPreferences = app.changeTextPreferences = null;  
s = app.documents[0].stories[0]; 
search(s, '&', '&'); 
search(s, '<', '&lt;'); 
search(s, '^t', '&nbsp;&nbsp;'); 
search(s, '^[', "'" );  
search(s, '^]', "'" );  
search(s, '^}', '"' );  
search(s, '^{', '"' );  
s.insertionPoints[0].contents = '<pre>';  
s.insertionPoints[-1].contents = '</pre>'; 
app.select(s.texts[0]); 
app.copy();

function search(s, from, to) { 
  app.findTextPreferences.findWhat = from; 
  app.changeTextPreferences.changeTo = to; 
  s.changeText(); 
}

Thanks Peter.

Dave
Re: Script Poster
#1661
Author: Harbs
Date: Mon, 02 Feb 2009 14:26
63 lines
1694 bytes
Here's another one which was posted on one of the other scripting forums (I don't remeber if it was Illustrator or Photoshop).

I changed it a bit because the original didn't work on my (Mac) computer. This one should work on both mac and Windows, and will work run under any program which supports ExtendScript (including the ESTK).




 
var asciiFile = new File(File.openDialog("Open File to convert","Javascript:*.jsx;"));  

var tempFolder = Folder.temp; 

OutHTM = new File(tempFolder.fsName + "/Code2HTM.txt"); 

asciiFile.open("r"); 

OutHTM.open("w"); 

var FileString = asciiFile.read(); 

asciiFile.close(); 

OutHTM.writeln("<PRE><BR>"); 

for (a=0;a<FileString.length;a++){ 

  c=FileString[a]; 

  Write(c); 

  } 

OutHTM.writeln("</PRE>"); 

OutHTM.close(); 

OutHTM.execute(); 

function Write(Char){ 

  switch (Char){ 

    case '\n' : OutHTM.write("\n<BR>"); 

    break; 

    case '\t' : OutHTM.write("  "); 

    break; 

    case '<' : OutHTM.write("<"); 

    break; 

    case '>' : OutHTM.write(">"); 

    break; 

    default : OutHTM.write(Char); 

    } 

  } 
Re: Script Poster
#1662
Author: Peter Kahrel
Date: Mon, 02 Feb 2009 14:34
28 lines
1329 bytes
I've pruned that script down to this:



#target indesign; 
tf = app.documents.add().textFrames.add ({geometricBounds: [0,0,'700pt','500pt']}); 
tf.insertionPoints[0].select(); 
app.activeDocument.textPreferences.typographersQuotes = false; 
app.paste(); 
app.findGrepPreferences = app.changeGrepPreferences = null; 
replace ('&', '&amp;'); 
replace ('<', '&lt;'); 
replace ('\\t', '&nbsp;&nbsp;&nbsp;'); 
replace ("'", "'"); 
replace ('"', '"'); 
tf.parentStory.insertionPoints[0].contents = '<pre>'; 
tf.parentStory.insertionPoints[-1].contents = '</pre>';

function replace (f, r) 
   { 
   app.findGrepPreferences.findWhat = f; 
   app.changeGrepPreferences.changeTo = r; 
   app.activeDocument.changeGrep () 
   }



Peter
Re: Script Poster
#1663
Author: Peter Kahrel
Date: Mon, 02 Feb 2009 15:26
5 lines
713 bytes
HArbs,

Spotted your script only now. Nice one.

Peter
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads