Cool Mac Gear



Tex Edit Plus And AppleScripts For HTML Markup And More

6608
Applelinks reader John Threadgold wrote:

Charles,

I am using Tex-Edit Plus for my list making and enjoy its functionality and (apparent) simplicity. You might remind us of how you make best use of it.

Enjoy your columns as always,

John T.


As John is aware, I've long been a super-big fan of Tex Edit Plus, Tom Bender's powerful and versatile little shareware text editor, which I've used since the early '90s for drafting articles and correspondence, for cleaning up text from emails and downloaded from the Web, and for converting text documents to HTML for Web publishing. Indeed, For the past seven years or so I've rarely used full-featured word processors for text crunching except in the relatively rare instances when I need a formatted document, but most of the time I work in plain text.

Happily, if you do require a word processor, there are several excellent ones available for OS X, Microsoft Word if you must, but there are lots of alternatives. I'm very impressed the German application Papyrus, but there are also Nisus Writer Express, Mellel, Mariner Write, ThinkFree Office and Apple's Pages, not to mention Open Source contenders like OpenOffice and AbiWord.

Actually, Tex Edit Plus 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's absolutely superb implementation of AppleScript, Apple's English-like programming language that allows you to use Apple Events to control applications, the slickest and best at this of any program I've ever used.

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." Indeed. Tex Edit Plus is one reason why I thank myself every day for choosing a Mac. AppleScript is another.

Tex Edit Plus's AppleScript configuration could hardly be smoother 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; Apple Events allow “scriptable� applications to communicate at a very intimate level. 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), are stored in a folder 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.

The Classic version of TE+ is one of the great Mac applications of all time, but the OS X version is even better, retaining all the goodness of its predecessor, and adding some cool new stuff like the ability to support the built in OS X spellchecker, the lack of spellchecking being perhaps the biggest shortcoming of the Classic application. There is also a new floating tool palette that can be displayed or hidden with a keystroke. Files created with either the OS X or the Classic versions of TE+ are fully forward and backward compatible. (TE+ is so far only PPC native, but it's so fast performance under Rosetta will be perfectly accceptable).

To run a script, you just open the menu and click on a selected script title, or use the optional 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.

image

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. ("ScriptName_0"), or for a function key shortcut, append underscore-Fkey. ("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 Apple Script Editor utility that is included with the Mac OS. As Doug Adams who operates the http://www.malcolmadams.com/te/ 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 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 Web page authoring application, but I am not enchanted with typing a lot of tedious little HTML tags.

http://www.barebones.com/products/bbedit/index.shtml Bare Bones Software's BB Edit 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 BB Edit.

On the other hand, BB Edit lists for $125, and Tex Edit Plus sells for just $15. Basically, as Doug Adams noted, 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.

Here is how I build an HTML page using Tex Edit Plus.

First I need the text. Columns and reviews are written mostly from scratch, while news briefs may include a fair bit of pasted in text from press releases and such. I usually rough out my articles longhand on paper and then dictate them into a Tex Edit Plus using iListen. Pasted in URLs and e-mail addresses are then added, and the article proofread and spellchecked to remove (not always 100 percent successfully, alas) those pesky, perfectly spelled, non-sequitur typos peculiar to dictation software.

Once the article is finished the writing and initial proofing, I want to convert it to plain, black, 12 point size, text, so I select my "Styleset" AppleScript, which looks like this:




I use Comic Sans or Geneva font as a good, readable, screen fonts, but they get that converted to a generic, monospace font anyway in the next step.

That next step and he is to convert the document to basic HTML. The tool that I use for this is the Mac -> HTML/F6 script which comes bundled with Tex Edit Plus. This script is based on: Script2HTML 1.0.2 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 (

)
tags, and a many cases what I really want is just a line break, so this little script called "Insert Break" makes the switch on highlighted sections of text:




Plain bullets aren't handled gracefully by Web browsers, so the next step is to convert bullets to "•" HTML Tags using this script:




To turn URLs and e-mail addresses into clickable Web links, I then apply the appropriate one of these two scripts:







Or 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 Matt, where you can find more than 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 here:
http://www.dougscripts.com/texedit/scripts/scripts05.php

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:




Or the blue font color I use in Mailbag columns to distinguish my 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:







Other useful AppleScripts I downloaded from Doug Adams' Website color all HTML tags in a document making it easier to proof read, 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 a markup is all done, the result is a document that when named with a html suffix can be opened with a Web browser as a formatted page -- essentially it is a Web page.

For Applelinks articles I then copy the title and body text of the document and paste them into a template that adds the Applelinks Web page formatting, links, and graphics, and then copy and paste that into a CGI posting engine using a browser.

This system works well for me, and gives me more precise control of the appearance of an article, and generates very clean text copy which is relatively easy to proofread and modify.

The AppleScripts described here do what I need to get done in HTML, but of course pretty much any HTML markup or text formatting function can be recorded and automated as AppleS and andcript.

As noted, you can download most of the scripts mentioned here (and many others) from Doug Adams's site here:
http://www.malcolmadams.com/te/

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 break tags

• 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 - uppercasesselection

And of course, AppleScript can be employed to do many more things in Tex Edit Plus than HTML markup. Most any repetitive task you use can probably be AppleScripted. Stylesheets are a good example.

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 inter-office 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 the company newsletter.
• View, edit and print text documents created by virtually any word processor or computer.
• Reformat downloaded e-mail 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 e-mail, 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.

Tex-Edit Plus is shareware, so you can download and try it out for free to see if it does what you need it to do.

System requirements:
• Mac OS X 10.1 or higher (Classic version still available as well)

Tex-Edit Plus X is $15.00 shareware

For more information, visit:
http://www.tex-edit.com/

Digg this

del.icio.us

Charles W. Moore

Posting Comments Requires Membership

Login   or   Register    

Name:

Email:

Location:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:


Most Popular

iPod




iPhone

iLife

Reviews

Software Updates

Games

Hot Topics

Login   •   Register   •   Contact   •   Newsletter   •   Advanced Search  •