%!ps % fixamp01.psl % Changes "01.asp" to "01.shtml" in an xhtml document % ========================================================== % by Don Lancaster % Copyright c 2009 and earlier by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is optional for this program. % After obvious location mods, uncomment ONE of the following two lines: % (C:\\gonzo2\\gonzo.ps)run % use internal gonzo % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % Gonzo is available as http://www.tinaja.com/post01.asp#gonzo with a % tutorial at http://www.tinaja.com/glib/gonzotut.pdf %%%%%%%%%%%%% % Newer versions of XHTML demand that all text ampersands are in a "&" % format. This PostScript program attempts to take a mix of uncorrected % and corrected ampersands and replace them with all correctly formatted. % Note that a bug in Dreamweaver will sometimes trash any internally % attempted corrections. And that eBay, government sites, and many % search documents may include dozens of ampersands per link. % The following algorithm is used: An iccoming file is character by % character copied to an output file. IF there is not a semicolon % within the next SEVEN characters and IF less than seven characters % from the end of the file, a "amp;" character sequence is inserted. % Note that other xhtml sequences (such as > or   might % have a variable number of characters between the ampersand % and the semicolon. And that the algorithm might rarely fail % on a non xhtml sequence that has both ampersands and semicolons % in it. % Also, ampersands inside JavaScript, Visual Basic, or other scripts may % need hand repatched. % To use, edit as a standard ASCII text file and send to Acrobat % Distiller. Distiller versions newer than 8.1 default to prohibiting % file writes and must be activated by a "run acrodist -F from the % Windows command line. % At present, input, output, and program files must be in the same folder. % Note that an "Empty Job - No File Produced" is normal and expected. % An excerpt from the Gonzo Utilities.... % mergestr merges the two top stack strings into one top stack string /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def % /correctampersnds is the high level routine to do the actual corrections. % Presently limited to 10 Meg or smaller files. /searchstring (01.asp) store /placestring (01.shtml) store /processreadfile { dup == dup length string cvs % dereference /derefstring exch store derefstring searchstring search {hit}{miss} ifelse } store /hit { /pre exch store pop /post exch store writefile pre writestring writefile placestring writestring writefile post writestring writefile (\n) writestring % end of string } store /miss {/whatleft exch store writefile whatleft writestring writefile (\n) writestring % end of line } store /correctasps { /readfilename fileheader infilename mergestr store /readfile readfilename (r) file store /writefilename fileheader outfilename mergestr store /writefile writefilename (w+) file store /linestring 1000 string store % length of input string 0 1 10000 { % for a bunch of lines readfile linestring readline dup == not { writefile exch writestring writefile (\n\n) writestring exit} if processreadfile } repeat readfile closefile writefile closefile } store %%%%%%%%%%%%%%%%%% demo - remove or alter before reuse %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % /fileheader (C:\\Documents and Settings\\don 2\\Desktop\\aanewsand\\weblib01\\)def /infilename (weblib01.shtml)def /outfilename (weblib01x.shtml) def % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% correctasps % this does it % EOF