I love Textile. All of my blogs use Textile. In some cases I have even extended Textile to provide additional features, making it a simple matter to add programmatically complex functions with a few extra characters.
Sometimes, though, I like to write my articles off-line and post them later. When I do, I typically use either TextMate in OS X, or Vim (wherever I am, sometimes in an SSH session). Unfortunately, though, there isn’t a lot of support for Textile in VIM. But after a little Googling, I found some.
About a year and a half ago, Dominic Mitchell posted his own Textile syntax file for Vim on his blog. I snapped it up and started using it. There is a slight problem, though, in the way it handles Textile URLs. Apparently thanks to the regex pattern for URL strings lifted from RFC 2396, it allows spaces in URLs, which causes the highlighting to continue after the URL ends.
I’ve applied a fix to the script and posted it here in case anyone (other than me) is actually interested in this sort of thing. Thanks much to Dominic Mitchell for creating this syntax file in the first place; I was not relishing the thought of diving in and creating one myself.
Revised Textile syntax file for VIM
If you wish to use the *.textile extension, as TextMate does, to indicate which files contain Textile syntax, you will want to add the following line to your filetypes.vim, which is located wherever your ftplugin directory is located (on my machine it’s /usr/share/vim/vim62/, but it will be different per-installation and wildly different in Windows):
Wow, you just posted this barely a week before I went hunting for it. Rock! Thanks!
You’re quite welcome, Shadowfiend, but thank Dominic for actually writing the thing!
Hello, thanks for the post.
I’m searching for a way to convert textile formatted files to html offline. I mean on my desktop, for example with vim, or anything else. I’d like to generate html offline, and upload them on my server.
Do you know probably a way to do this?
Is it possible maybe with the classTextile.php?
Thanks
Hi Darvas, thanks for reading.
I don’t know of a turnkey way to do what you want to do. It’s definitely possible to install PHP on your local machine and run it from the command line to HTML-ize your textile using classTextile.php. You could even create script and mapping definitions within VIM to pipe the buffer through it, but I don’t have any code to show you.
If you work anything out, let me know!
It has just come to my attention that the Mac OS X editor that I normally use while editing offline on my Mac, TextMate (which I can’t recommend enough), does support converting textile documents into HTML. Just FYI.
Naturally, thanks are due to Dominic as well
Also, for converting — another way is to install Ruby and then install the RedCloth gem. Then a simple Ruby script can easily convert it using RedCloth. A better alternative is SuperRedCloth (see http://code.whytheluckystiff.net/redcloth/wiki/SuperRedCloth), which is way faster and more correct.
Re: Locally generating HTML from Textile, if you’re comfortable in Perl, another option is to write a very simple wrapper around Brad Choate’s Text::Textile (see http://search.cpan.org/~bchoate/Text-Textile-2.03/).
Lack of textile support in VIM is no more!
Introducting Textile for VIM:
http://www.vim.org/scripts/script.php?script_id=2305