Posts tagged with “Unix Filter”

October 16

More unix filters

I've built some more unix filters for Text Wrangler, each quite simple but useful.

Lynx

The filter sends the whole document or selected text the Lynx browser. This shows me what a web page or snippet will look like without CSS styling. I can then use the style filter to check readability based on the Lynx output.

#!/bin/sh
# From TextWrangler sends document or selected text
# to lynx which then dumps to stdout
#
lynx -force_html -nostatus -nolist -dump "$1"

PHP

The filter sends the whole document or selected text to PHP. I find this useful for testing my PHP code. This filter does not work with code from include files.

#!/bin/sh
# From TextWrangler sends document or selected
# text to php which then dumps to stdout
#
php -f "$1"

Redcloth

Redcloth implements Texttile text processing using ruby. I'm starting to write portions of web documents with texttile formatting. Redcloth processes the texttile mark up and outputs HTML. Redcloth 3.0.4 seems to implement a subset of texttile formats: it does not understand bc. block code. Redcloth 4.04 does understand bc.: I installed 4.0.4 using gem. Works as advertised.

#! /bin/sh
# From TextWrangler sends document or selected
# text to redcloth which then dumps to stdout
#
redcloth "$1"
12:13 PM | Tags: , , , ,
October 06

traveling in style

When I write I try to check the readability of my work. I use GNU style for this task. Style analyses a document, including sentence length and other readability measures. It comes with the program diction that identifies wordy and commonly misused phrases.

Install MacPorts by downloading the Mac OS X package and running the installer.

Install diction using the port command.

Use:

/opt/local/bin/style [/path/to/the/file/you/want/check]

If you want to avoid using the full path to style each time then you could add /opt/local/bin: to the path in .bash_login in your home folder.

I use a UNIX filter in TextWrangler to send either the whole document or selected text to style for checking. Put it in the Unix Filter folder of TextWrangler and access it from the #!@ shebang menu. Hold down the [Apple] key when you click on a Unix Filter to view filter options.

#!/bin/sh@<br>
# TextWrangler sends the whole document or selected text to style@<br>
# -p outputs passive sentences@<br>
/opt/local/bin/style -p "$1"@
01:30 PM | Tags: , , ,