Easily encoding documents prior to publishing them to the web


While reviewing the command lines on commandlinefu, I came across this nifty little gem:

$ perl -MHTML::Entities -ne 'print encode_entities(_)' FILETOENCODE

This command line snippet takes a file as an argument, and escapes all of the characters that can’t be directly published on the web (i.e., it will convert a right bracket to & gt). This is super useful, and is a welcome addition to the nifty tidy utility!

This article was posted by Matty on 2009-02-13 12:13:00 -0400 -0400