« The Gutenberg Bible | Home | Prepare for the upcoming campaign season »

Movable Type Syntax Highlighting for TextPad

posted by David on July 25, 2003 at 04:58 PM

After downloading the MT clip library that Andre Torrez created for TextPad, I decided to make a syntax highlighting file to take full advantage of the new clips. (If you’ve never used a custom syntax highlighting file in TextPad, it gives you the ability to choose which colors are used to display different aspects of various languages.)

I ended up just adding the MT syntax to the existing php4html.syn file that combines PHP4 and HTML because I use all three of those languages in combination on most of the sites that I work on these days.

I made two versions of the syntax file. The one you choose will depend on which language you want the most detail for.

mph222.syn has two groups of keywords for each language:

  • Keywords 1 : HTML tags
  • Keywords 2 : HTML attributes
  • Keywords 3 : MT tags
  • Keywords 4 : MT attributes
  • Keywords 5 : PHP language keywords and constants
  • Keywords 6 : PHP functions

This gives you more detail in looking at your MT and HTML tags. Attribute values for MT and HTML will be in a third color determined by a built-in TextPad .syn file. If you do most of your work in MT and HTML and only do basic PHP scripting, this might be a good choice for you.

mph114.syn has one group of keywords for MT, one group for HTML, and four groups for PHP:

  • Keywords 1 : HTML tags and attributes
  • Keywords 2 : MT tags and attributes
  • Keywords 3 : PHP basic language keywords
  • Keywords 4 : PHP constants
  • Keywords 5 : PHP functions (also applies to functions for some other web scripting languages)
  • Keywords 6 : PHP database and grouped functions

This gives you less detail in looking at your MT and HTML tags and attributes, although attributes values for MT and HTML will be in a third color determined by a built-in TextPad .syn file. Conversely, you’ll have much more color detail in your PHP code. If you are comfortable with MT and HTML and do a lot of complex PHP scripting this file might be a better choice for you than mph222.syn.

If it sounds good to you, follow these steps.

  1. Download mph222.syn or mph114.syn. Put the file in TextPad/Samples, and restart TextPad.
  2. After TextPad has restarted, go to the “Configure” menu and select “New Document Class …” to start the New Document Class wizard.
  3. Create a name for the document class (I used “MT+PHP+HTML”)
  4. Decide what kind of documents (class members) should use this syntax. I made one up called “*.mph”. That way I can leave the PHP document class for straight PHP and the HTML document class for straight HTML. (Make sure to use the asterisk so that all your .mph files can use the syntax highlighting.)
  5. Check the box that says “Enable syntax highlighting” and from the pull-down menu, select the .syn file that you just downloaded.
  6. Verify that everything is the way you want it and click the “Finish” button.

Once you’ve got the .syn file installed, you can go to Configure:Preferences:Document Classes:MT+PHP+HTML (or whatever you called your class) and play around with the colors.

If you have any corrections, suggestions, or improvements, or if you’re having problems with the file, please let me know. (Comments on this page are automatically emailed to me.)


Comments

I assume this has to do with more advanced programming than I am able to do. Dad

Comment posted by David | August 1, 2003 05:44 PM

hello !
In query how to highling the key words in richtext box can it be the colletion of key words and rotating from the file with a loop ??

Comment posted by | November 18, 2003 12:07 AM

It works very well. Thanks.

Comment posted by Pépé Râleur | April 6, 2004 11:47 PM

Thanks for the useful info concerning TextPad syntax highlighting.

I was very moved by your tribute to your departed companion, Auggie Doggie. We recently had to say goodbye to our oldest canine friend, Mikey, and I would have liked to haved written a memorial such as yours.

Best wishes,
Ingo.

Comment posted by Ingo | January 31, 2005 12:37 PM

This discussion has been closed. Thanks to all who participated.