« Snap! Talk to the hand. | Main | Pool in the Spree »
October 08, 2004
Using Textile with HumaneText Service for OSX
Textile is a fantastic thing, which makes writing valid XHTML quick, easy and reliable. It converts text from an easy-to-learn syntax to valid XHTML automatically. It also correctly formats ampersands and copyright symbols, even tables and lots more, freeing you from needing to memorize all those character codes. (If you’re using MovableType, install the plugin and don’t look back.)
Now, I’ve also recently started realizing how amazing OSX’s Services menu is. For example, did you know the system-wide keyboard shortcut Shift-Apple-Y? It makes a new Sticky note from any selected text. Quite useful for keeping URLs and email addresses around.
To me, one of the most useful of all Services is HumaneText.service , which lets you convert text to HTML and vice versa in any text you write anywhere in OS X—any textfield on any webpage you have open in Safari, any text you’re writing in your text editor, even in Word—can be immediately converted to valid XHTML. Maybe it’s just because I learned Textile first, but I prefer Textile over John Gruber’s similar Markdown format. Unfortunately, HumaneText.service doesn’t support Textile by default.
If you prefer Markdown format, you can download and install the HumaneText service in a minute or two and be done with it. You can use Textile with it too, though you’ll have to configure it yourself. I couldn’t find instructions on how to do this for Unix laypeople like me, so here’s what I figured out instead of watching the presidential debate this evening. You’ll need a text editor and some minor confidence with the Unix command line, but the changes you’ll make are very easy and safe. It’s a simple 14-step process!
Note: these instructions seem not to work work with HumaneText.service version 5, which was current in Februay 2005.
Note: after any step below that tells you to type some text, hit the Return key after you type the text.
1. Download the current version of HumaneText
2. Download Textile itself. Rename this file to simply “textile.py” (in other words, remove the “.txt” ending).
3. Right-click on the HumaneText.service file and choose “Show Package Contents”.
4. Navigate this new window to the Contents/Resources/ directory (other files in there include “Markdown.pl”. Put your copy of “textile.py” into that directory.
5. Open textile.py in any text editor (not Microsoft Word). Apple’s TextEdit program works fine.
6. Add the text following as the very first line in textile.py: #!/usr/bin/env python
7. Save and close textile.py
8. Open the Terminal application.
9. Type cd ~/Library/Services/HumaneText.service/Contents/Resources/
10. (optional) If you want to see the files in this directory, type ls -l
11. Type rm forward
12. Type ln -s textile.py forward
13. Type the word exit to close your Terminal session.
14. Log out and back in again.
You’re all set. Open a new Sticky note and type h1. Textile. Select what you just typed and choose the menu item Stickies>Convert Humane Text>Text to XHTML. Your text should be converted to XHTML tags. Try some of the other Textile syntax too.
Posted by Andrew at October 8, 2004 08:43 PM
Comments
Awesome, I always wondered how to switch this - I think the part I missed before was adding the python line to the top of textile.py - DOH!.
Thanks again.
Posted by: Shawn at January 7, 2005 03:01 PM
Yes, it’s really odd that the copy of textile.py that’s included with Humane Text Services needs to be changed like this.
Posted by: heyotwell
at January 7, 2005 03:15 PM
Thanks for posting this tip! However, I just tried it, and cannot get it to work. I have the latest version of HumaneText (No. 5) and followed your instructions — twice. But now it converts xhtml to Markdown, and does nothing the other way around (whether I type in Textile or Markdown, it leaves it as it is). Any idea what I could be doing wrong?
(Edited textile.py in SubEthaEdit, and when doing the Terminal stuff I first copy-pasted directly from this site, but the second time I copy-pasted to SubEthaEdit first and then from there to the terminal, to make sure I didn’t have any excessive characters/spaces…)
Posted by: Dan Brendstrup at February 23, 2005 02:41 PM
Hm, HumaneText No.5 has textile.py missing. Dang. I wish now I hadn’t copied over No.4.
Posted by: jeff at February 24, 2005 12:27 AM