banner

MetaPost in TextWrangler

Since TeXShop does not support syntax coloring for MetaPost (yet), I use TextWrangler to write my MetaPost programs. The TextWrangler’s syntax definition file included in the archive at the bottom of this page offers

Besides, the archive includes some AppleScript scripts that can be used to typeset MetaPost programs using my engines directly from TextWrangler and preview the result in TeXShop or in another PDF viewer.

Requirements

The scripts require my TeXShop engines for MetaPost.

Installation

  1. In the Finder, browse to ~/Library/Applications Support/TextWrangler (~ is a shorthand for the path to your home folder).
  2. Copy MetaPost.plist into the Language Modules folder (create the folder if it does not exist).
  3. Copy the .scpt files into the Scripts folder (create the folder if it does not exist).
  4. Re-open TextWrangler.
  5. Go to TextWrangler > Preferences… > Languages. In the Suffix Mappings list you should see that the .mp suffix is associated to MetaPost syntax.
  6. Add another suffix mapping by clicking on the Add… button. In the dialog, write .mf in the Extension field and choose MetaPost from the Map to: pop-up menu. Click Add. Close the Preferences window.
  7. Go to Window > Palettes > Scripts to open the Scripts palette.
  8. Open a .mp or .mf document, and double-click on one of the scripts in the Scripts palette.

If there are no compilation errors, you should see the resulting PDF in TeXShop. If there are compilation errors, the log file is automatically opened in TextWrangler.

Customization

Q: How to change the PDF previewer?

A: Open Compile MetaPost.scpt and Compile MetaFun.scpt with the AppleScript Editor (which is located in /Applications/Utilities) and change the line that reads

property PDFVIEWER : "TeXShop"

to your favourite PDF viewer. For example, if you want to view the PDF in Skim, use

property PDFVIEWER : "Skim"

If you want to use Preview, use

property PDFVIEWER : "Preview"

and so on. Then compile and save the script.