Low End Mac Reader Specials
TypeStyler For Mac OS X is Now Shipping! Download The Free Fully Functional 60 Day Tryout at www.typestyler.com
Don't install Parallels to play poker online! Poker Mac will show you how
to download and install a native Mac poker application such as Full
Tilt Poker Mac.
Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.
Compare products like desktop computers, apple laptops, apple macs, and LCD Monitors side by side! All the information and reviews to make the best purchasing decision for new mobile phones, sat nav systems, or MP3 players. The Ciao online shopping community makes searching products easy for you.
Miscellaneous Ramblings
Using Tex-Edit Plus and AppleScript for HTML Markup
Charles Moore - 2009.10.19 - Tip Jar
Follow Low End Mac on Twitter.
Popularity: ![]()
![]()
Tweet this article. Short link: http://bit.ly/17mFWw
LEM reader Bruce writes:
Agreed that Tex-Edit Plus is a great product.
But I'm always curious about how people actually USE AppleScript features.
Got comments on this? As a reply or as a column; would be great to hear about.
Bruce
That's an excellent idea for a column, so read on to learn how I use AppleScript in Tex-Edit Plus (TE+) - but first a few notes about the application itself.
If you're a fan, or just curious, it should be noted that it's been a while - since July 29, 2007 to be precise - since TE+ received a version update. Developer Tom Bender has been occupied with other things in the meantime, but it's testimony to the solidity and robustness of the program that it continues to work just fine, at least in OS X 10.5.8 "Leopard", which is the version of OS X I'm still using.
Thus, I can't speak to whether there have been any issues with TE+ 4.9.8 - the current final version - in OS X 10.6 "Snow Leopard". I haven't heard of any problems, but if anyone out there can report, I'd be interested in hearing. Tom told me late last year that he intended to get back to updating and improving TE+ in 2009, but so far the only update development has been the posting on April 27 of version 4.9.9 beta 1 - a minor tweak that improves memory handling when saving files that contain big resources (e.g. TIFFs). I'm running 4.9.9b1, and it's stable and reliable under OS X 10.5.8.
Hopefully, Tom will see his way clear to keep Tex-Edit Plus current, because this application is one reason why I thank myself every day for using a Mac, and AppleScript is another. The combination of the two makes this program a "killer app" for my purposes.
TE+'s AppleScript implementation could hardly be smoother, slicker, or more user-friendly. Scripts, which, if you're not familiar with AppleScript, are sort of mini-applets or macros that automate a particular function (actually, they're more than macros). As Tom Bender puts it: "AppleScript puts the power of these Apple Events in the hands of the ordinary user. It's just another insanely great advantage that we Mac users enjoy."
TE+ also has a nice inventory of text cleaning tools, a decent find and replace engine, and supports OS X's built-in spellchecker. I use it as something of a do-all and "can opener" app - able to open a wide selection of text formats to at least give you a look at what's inside.
Since the mid 90s, I've used TE+ almost exclusively for day-to-day text crunching like drafting articles and correspondence, cleaning up text from emails and downloaded from the Web, and, thanks to AppleScript, also as an HTML markup program for converting and preparing documents for online publishing. I rarely use full-featured word processors any more, except in the relatively rare instances when I need a heavily formatted document. Most of the time I just work in plain text.
Actually, Tex-Edit Plus itself supports a fair bit of formatting when you need it, and anything you do with this application can be facilitated and streamlined by Tex-Edit Plus' absolutely superb AppleScript support.
Unlike macros, Apple Events bypass the user interface and are exceptionally efficient. Scriptability implies that the programmer has given AppleScript access to major portions of the application's inner workings. Scripts are stored in a folder (logically called "Scripts") in the Tex-Edit Plus application folder and appear in an AppleScript menu when Tex-Edit is running. When you add new scripts to the folder, they show up in the menu instantly without your having to restart the program.
There is also a floating AppleScript tool palette
(right) that I actually had something to do with. As Tom Bender notes
in the TE+ Version 4..8 changelog :
"{a] Handy new floating Script Tools palette thanks to Charles W. Moore. Compiled scripts added to the new 'Script Tools' folder will show up as buttons in the palette. Option click a button to edit its script. Jaguar (10.2) or newer required."
To run a script, you just open the menu and click on a selected script title, or use the aforementioned floating Script Tools palette. Compiled scripts added to the new "Script Tools" folder will show up as buttons in the palette. Option click a button to edit its script.
Even better, for scripts that you really use a lot, it is more convenient to assign keystroke shortcuts to activate them, which is done by simply appending an underscore-character suffix to the script's name. (e.g.: "ScriptName_0"), or for a function key shortcut, append underscore-Fkey. (e.g.: "ScriptName_F5"). You can also configure various modifier keys in your keyboard shortcuts. For example, with the script Mac -> HTML_F6, press the F6 key and a copy of your document gets converted to HTML while you watch.
A couple of dozen or so AppleScripts are bundled with the Tex-Edit Plus standard download, and because Tex-Edit Plus is recordable, you can record custom scripts of your own to automate tedious or frequently repeated tasks using the AppleScript Editor utility that is included with the Mac OS. As Doug Adams, who operates the Tex-Edit Plus AppleScripts Website, notes:
"I learned AppleScripting with Tex-Edit Plus, and I am always disappointed when I open the dictionaries of other scriptable apps to find them nearly barren. A few commands and objects alongside the Standard Suite does not a scriptable application make.
"But here we have the new version of Tex-Edit Plus. Virtually everything can be scripted. That is extremely rare in an OS X app (Mail, iTunes, and Safari are wonderful exceptions). Even more importantly, you can script Tex-Edit Plus to perform tasks Tom Bender never dreamed of when he was programming it. For example, Tom didn't build an HTML editor into TE+. But you can very easily create the tools you need to make HTML tags, and then send docs via FTP, analyze server logs, write CSS, RSS, JavaScript, PHP. Tex-Edit Plus is at the heart of my day-to-day operations - it's always on."
I agree. Tex-Edit Plus is, as noted above, my "do almost everything" application.
The scripts I use most often with Tex-Edit Plus relate to things like converting text from/to lower/upper case, capitalization (yes, I know there are submenu commands in Tex-Edit Plus that can do this too, but an AppleScript with a single keystroke shortcut is faster and slicker), and HTML markup. I prefer to create HTML documents from scratch, and as I work, rather than using a WYSIWYG authoring application, but I am not enchanted with typing a lot of tedious little HTML tags.
Bare Bones Software's BBEdit is an excellent tool for doing this sort of HTML markup. But for my purposes, it has always seemed like overkill. My HTML authoring needs are not complex, but if yours are, check out BBEdit.
On the other hand, BBEdit lists for $125, and Tex-Edit Plus sells for just $15. Basically, as Doug Adams notes, AppleScript allows me to add just the HTML markup capability I need and want without a lot of other selections that I never use and which just get in the way.
Building an HTML Page with Tex-Edit Plus
Here's how I build an HTML page using Tex-Edit Plus.
First, I need the text. Columns and reviews are mostly written from scratch, while news briefs may include a fair bit of text pasted in from press releases and such. I often rough out articles longhand on paper and then dictate them into a Tex-Edit Plus using MacSpeech Dictate. Pasted-in URLs and email addresses are then added, and the article proofread and spell checked to remove those pesky, perfectly spelled, non-sequitur typos peculiar to dictation software (not always 100% successfully, alas).
Once
the article is through the writing and initial proofing, I want to
convert it to plain, black, 12 point text, so I select my "Styleset"
AppleScript.
I use Comic Sans or Geneva as a good, readable screen fonts, but they get converted to a generic, monospace font anyway in the next step, which is to convert the document to basic HTML.
The tool I use for this is the Mac -> HTML/F6 script that comes bundled with Tex-Edit Plus. This script is based on Script2HTML by Bill Cheeseman. The conversion process takes a few seconds and results in a copy of the original document in simple HTML form, leaving the original draft untouched. There are several other AppleScripts that will convert text to HTML, some that do a fancier job, but for my purposes I'm better off with the simpler one.

The Mac -> HTML/F6
script converts all hard returns to paragraph (<p>) tags, and in
many cases what I really want is just a line break, so this little
script called Insert
Break (left) makes the switch on highlighted sections of
text.
Plain bullets aren't handled gracefully by Web browsers, so my next step is to convert bullets to "•" using the to &149; script (right).

Scripts to turn URLs and email addresses into clickable links.

To turn URLs and email addresses into clickable Web links, I then apply the appropriate one of these two scripts (right).
If I want to convert a piece of text to a clickable web link, I use the Selection->Link script by Andrew Sasaki, which is downloadable from Doug Adams' Tex-Edit AppleScript archive, where you can find some 200 free, downloadable AppleScripts. Most of the ones mentioned in this article, including my own little batch of recorded scripts called "HTML Suite", can be found on that site.The Selection->Link script takes a text selection in Tex-Edit Plus and makes it into a web link. It's smart enough to handle URLs and plain text differently.
For many articles, that completes the HTML markup stage, but often there are other formatting jobs to add, such as:
Blockquoted blocks of text
Bold for headings or emphasis
Bold plus a point size boost for even more emphasis
Centering blocks of text or tables
Apply the blue font color I sometimes use
to distinguish replies from readers' letters.
I also have a couple of scripts that create clickable text references and target couples within a Web page, such as jumping from a Table of Contents entry to the subhead for that topic in the column or article:

Scripts to create and use anchors.

Other useful AppleScripts I downloaded from Doug Adams' website color all HTML tags in a document, making it easier to proofread or create HTML tables.
Jerome Koons' Create HTML Table makes an HTML table using user-supplied variables. It can be used in conjunction with the Create Anchor Refs script to place anchor references in the table.
When markup is done, the result is a document that, when named with a .html suffix, can be opened with a browser as a formatted page - it is essentially a web page.
This system works well for me and gives me more precise control of the appearance of an article. It generates very clean text copy that is relatively easy to proofread and modify.
The AppleScripts described here do what I need to get done in HTML, and pretty much any HTML markup or text formatting function can be recorded and automated as an AppleScript.
As noted, you can download most of the scripts mentioned here (and many others) from Doug Adams's site here.
My own HTML Suite, which can be downloaded there, is a collection of fifteen scripts to assist in creating HTML formatting.
- Styleset - changes all text to uniform plain text style
- Anchor - converts a selected URL into a weblink
- Insert B - makes selection boldface
- Insert B BIG - makes selection boldface and larger point size
- Insert BLOCKQUOTE - formats selection as blockquote
- Insert center - centers selection
- Insert Break - inserts a line break
- mailto - converts selected email address to weblink
- -> • - converts Mac bullets to standard HTML bullets
- (P to BR) - converts paragraph tags within a selection to line breaks
- target reference - adds link for target text within a Web page to selected text
- target - adds tags for text target within a Web page to selected text
- Insert Fontcolor - inserts font color tags
- select all - selects contents of open window
- Casecap - capitalizes selection
- Caselow - lowercases selection
- Caseup - uppercases selection
Of course, AppleScript can be employed to do many more things in Tex-Edit Plus than HTML markup. Most any repetitive task you do can probably be AppleScripted. Stylesheets are a good example. Tex-Edit is "recordable" as well as "scriptable", and you can use Script Editor to record your actions as you use Tex-Edit, creating a script that you can save and use to repeat the action later by activating it with a menu command.
With Tex-Edit Plus you can:
- Quickly create, edit, and print styled text documents of any size (limited by RAM).
- Use powerful regular expression search and replace functions.
- View and print TeachText or SimpleText read-only ("ReadMe") documents.
- Play QuickTime movies.
- Insert attention-getting sound annotations to spice up ordinary interoffice mail
- Easily create TeachText/SimpleText read-only documents, including embedded pictures.
- Read and create RTF files.
- Read and create UTF-16 (Unicode) text files.
- View and print color PICT files, such as those produced by draw programs or Apple's built-in screen snapshot utility.
- Copy a selection from a PICT file, cropping the image for use in a document.
- View, edit, and print text documents created by virtually any word processor or computer.
- Reformat downloaded email or text, correcting word-wrap problems and removing extraneous, non-Mac characters.
- Prepare text for upload to the Internet, so that people with Wintel or Unix systems can view the document as it was intended to be viewed.
- Instantly quote a brief passage from received email, allowing the sender to remember their original message.
- Read any text document aloud. (Listen to a SimpleText read-only file, for example, as the text and pictures scroll by!)
- Quickly optimize a document for printing, replacing generic, typewriter-era characters with professional-looking typographically correct text.
- Create simple hypertext documents.
System requirements: Mac OS X 10.1 or higher (Classic version still available as well)
Tex-Edit Plus is $15 shareware, so you can download and try it out
for free to see if it does what you need it to do.
Further Reading
- Tex-Edit Plus: Powerful Styled Text Editing for OS X and the Classic Mac OS, Charles Moore's 2007 review of this program.
- Software Review: Tex-Edit Enhancer, Charles Moore's 2000 review of a popular, powerful add-on for Tex-Edit Plus.
Charles Moore has been a freelance journalist since 1987 and began writing for Mac websites in May 1998. His The Road Warrior column is a regular feature on MacOpinion, and he is a news editor and columnist at Applelinks.com. If you find his articles helpful, please consider making a donation to his tip jar.
Recent Miscellaneous Ramblings
- Pismo WiFi Networking Issue Finally Solved?, 11.24. It turns out the problems wasn't the Pismo, the Buffalo WiFi card, or Mac OS X 10.4. It was the Wireless G router - Linksys to the rescue!
- Why Spaces is My Favorite Leopard (and Snow Leopard) Feature, 11.23. Spaces, a feature introduced with OS X 10.5, is like having several monitors on your Mac without the cost and space of using multiple displays.
- Soft Touch Keyboards, Wireless Mouse Options, Loving SeaMonkey 2, and More, 11.18. Also the future of browsing with PowerPC Macs and the multiple mouse input bug introduced with OS X 10.5.8.
- 4 Mac Browsers Updated Recently, 11.16. A look at the release version of Safari 4.0.4 and preview versions of Firefox 3.6, Chrome 4.0, and Opera 10.10.
- More in the Miscellaneous Ramblings index.
Links for the Day
- Mac of the Day: Mac mini Core Solo, Feb. 2006 - The only Mac to use a Core Solo CPU, this model ran at 1.5 GHz, has integrated graphics, and includes a Combo drive
- Group of the Day: SuperMacs is for those using Umax SuperMac clones.
- November 24 in LEM history: 98: Microsoft's heavy hand - 00: Looking at the iMac - 04: The best Mac for the holidays - Picking the right replacement for a dead mouse - Better battery for 15" AlBook
- Support Low End Mac
Recent Content on Low End Mac
- Mini VGA to S-video Adapter a No Go for eMacs, Dan Bashur, Apple, Tech, and Gaming, 11.24. You might think that Apple's Mini VGA S-video adapter is a cheap way to connect your eMac or G4 iMac to your TV. You would be wrong.
- Google Calendar with iPhone or iTouch Is Great for Scheduling, John Hatchett, Recycled Computing, 11.24. Web-based Google Calendar allows access and updates from any computing platform, including Mac, Windows, Linux, and iPhone OS.
- i5 iMac Benchmarked, Mac mini 'Shouldn't Be Overlooked', Twitter Client for Classic Mac OS, and More, Mac News Review, 11.20. Also why Apple leaves the low end to others, 10.6.2 fixes video playback problem in 27" iMac, 3D Leopard and Snow Leopard performance, and more.
- Apple's Tablet an End Run Beyond Netbooks, Frank Fox, Stop the Noiz, 11.20. Whatever Apple has planned will leverage existing technologies while going beyond what its competitors can offer.
- Apple #4 in Reliability, Apple Tablet a Gadget for All?, HP's i7 Notebook Outdoes Mac Rivals, and More, The 'Book Review, 11.20. Also Flash 10.1 improves video on Hackintosh netbooks, thin-and-light notebooks impress, Windows XP finally on the way out, and more.
- NASA Chemical Sensor for iPhone, Smartphone Death Match, iPhone Earrings, and More, Ian R Campbell, 11.20. Also mobile phone dangers, new apps, GPS solution for iPod touch, new iPod and iPhone cases, and more.
- More links in our archive.
Recent Deals
- Best G4 iMac Deals, 11.24. Used 15" 700 MHz CD-RW, $150; 800 MHz Combo, $229; 1 GHz, $289; 17" 1.25 GHz, $200; 20" 1.25 GHz, $509.
- Best MacBook Air Deals, 11.24. Used from $899; refurb from $1,099; new 1.6 GHz/120 HD, $1,150 after rebate; 1.8/64 SSD, $1,150 a/r; 1.86/128 SSD, $1,350 a/r; 2.13/128 SSD, $1,694 a/r.
- Best PowerBook G3 Deals, 11.24. Used 233 MHz WallStreet, $75; 266 MHz, $160; 400 MHz Lombard, $199; 400 MHz Pismo, $289; 500 MHz, $350.
- Best 12" PowerBook G4 Deals, 11.23. Used 867 MHz SuperDrive, $348; 1 GHz Combo, $379; SD, $519; 1.33 GHz, $529; 1.5 GHz Combo, $549; SuperDrive, $609.
- Best Mac Pro Deals, 11.23. Used 2.66 GHz 4-core, $1,300; 3.0 4-core. $1,919; refurb 2.66 4-core Nehalem, $2,149; 2.93, $2,549; 2.93 8-core, $4,999; new 2.26 8-core, $2,290.
- Best Time Capsule and AirPort Deals, 11.23. Used 802.11g AirPort Extreme, $49; 500 GB Time Capsule, $150; new, $190; 1 TB dual-band, $280; 2 TB, $469; 802.11n AirPort Extreme, $170.
- Best eMac Deals, 11.18. Used 1 GHz Combo, $100; SuperDrive, $269; 1.25 GHz Combo, $119; SD, $319; 1.42 GHz Combo, $289; SD, $498.
- Best Mac OS X 10.6 and Mac Box Set Deals, 11.18. "Snow Leopard", single user, $25; 5 users, $45; Mac Box Set, single user, $139; 5 users, $180; Server, $414. Shipping included.
- Best Xserve Deals, 11.18. Used 1 GHz dual G4, $649; 2.3 dual G5, $795; 3.0 4-core Xeon, $1,899; refurb 2.26 4-core, $2,499; new, $2,888; refurb 8-core, $2,999; new, $3,449; more.
- More deals in our archive.
About LEM | Support | Usage | Privacy | Contacts
Navigation
Used Mac Dealers
Apple History
Video Cards
Email Lists
Favorite Sites
MacSurfer
MacMinute
MacInTouch
MyAppleMenu
InfoMac
Macs Only!
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac
Museum
DealMac
DealsOnTheWeb
Mac2Sell
ramseeker
Mac Driver Museum
JAG's House
System
6 Heaven
System 7 Today
the pickle's Low-End
Mac FAQ
Abandonware
Petition
Mac vs. PC Info
Affiliates
The Apple
Store
Mac
Connection
B&H
MacMall
TechRestore
ExperCom
Crucial
Memory
batteries.com
Advertise
MacMinute
MacInTouch
MyAppleMenu
InfoMac
Macs Only!
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac
Museum
DealMac
DealsOnTheWeb
Mac2Sell
ramseeker
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End
Mac FAQ
Abandonware
Petition
Mac vs. PC Info
Mac Connection
B&H
MacMall
TechRestore
ExperCom
Crucial Memory
batteries.com





