Tag Archives: cleanup

csstidy: Tidy and neat

I like tidy tools. I like tools that take my mess of HTML and turn it into the stuff of legend. No doubt if I was a programmer I’d think a similar tool for perl was as cool as sliced bread. csstidy presses that same button, and makes me wish I had a reason to use it.


As you can see there, csstidy lopped off the start of my ugly-as-sin HTML file, and sent me back a corrected, clean and spaced version, ready for editing or to be injected back into the file. It even went so far as to make some small improvements.

csstidy has a few options, which will reveal themselves to you if you invoke csstidy without a target. (Don’t try -h or --help.) Most of them are more than I would ever need to dress up my lowly web pages, but there might be something there that enthuses you.

Short of that, there’s not a lot for me to say about csstidy. I was scolded a long time ago for not coding like a girl, and I know I shouldn’t rely on tools like this if I ever want to be a rock-and-roll-web-page-designer, but hey … it works clean and neat for me. 😀

tidyhtml: Erasing your coding sins

Woe betide the uninitiated first arriving in the realm of HTML coding. Your work is shoddy, your style is crude, and your mismatched closing font tags belie the awful depths of your ignorance. Return to your hovel, peasant. Meditate on your sins and return when you have abandoned the wickedness of your ways.

Know ye first that this is foul. Slatternly. Slovenly.


Such petulance will be erased by repeatedly striking a rod across the palms. The HTML elite do not suffer such insolence.

This instead is the first step on the path of enlightenment:


Beauty. Elegance. Symmetry. Balance. Two-space indents. Only years of practice, asceticism and adherence to the principles of coding like a girl can produce such delicate, exquisite HTML.

The cultured elite can produce code of such perfection with ease. They do it daily. It is as natural for them as an eagle soaring on the wind.

For others, there are no shortcuts. Only toil and tedium. No easy path. No tricks or gimmi


What devilry is this?! Begone, you monstrosity! There are no short routes to achieving nirvana! Your sorcery will not go unpunished! The Yama kings gnash their teeth in anticipation of your arrival in the afterworld. 👿


perltidy: Picking up the loose ends

If you look closely at the screenshot here, you’ll see where perltidy was at work.


On the left, the venerable mp32ogg, which I picked because it was the first thing I could find that was written in perl and functional.

On the right, its doppelgänger in mp32ogg.tdy, and as scrubbed clean by perltidy.

I’m familiar with tidyhtml, which — as a nonprogrammer — I consider to be as important as washing my hands before I eat.

perltidy is new to me though, most likely because … well, because I don’t program, let alone program in perl. Which I suppose makes me a bit of a barrack-room lawyer.

Purists will tell you that perltidy is a crutch, that you should code like a girl anyway, and perltidy and its ilk make you a lazy coder.

Or you could take my uneducated endorsement, which is based on the long-standing presumption that computers should be doing our dirty work, and cleaning up our mistakes for us. 😉

fmt: And the difference is. …

Sam asked a good question after the fold post from yesterday. What’s the difference between fold and fmt?

Here’s fold on the top and fmt on the bottom.


First, fmt doesn’t want to break words. fold will, given the opportunity, and actually has to be told to wrap at spaces.

fmt will also correct some spacing issues. Tacking on the -u option pulls extra spaces and fills two spaces after a period. (My secondary school typing teacher would be proud.)

Plus, fmt also has some more sophisticated “margin” handling. You can tell fmt to push to within X percent of the wrap limit — a “goal” — and then break a line. I’ve seen word processors with that kind of feature, usually for hyphenation.

And judging by the man page, fmt tries to avoid breaking lines at the first word or before the last word, meaning it has some rudimentary widow and orphan control.

fmt can also set special indentations, split but not refill lines and screen lines before applying formatting.

So I guess the answer is … fmt seems a bit more attuned to formatting text in paragraphs, and making it presentable. Like designing a help page or cleaning up wordy output.

fold on the other hand, appears more attuned to straight lines of text … perhaps annotated code or something like that.

I am a newcomer to both though, so if there’s another use for either, please let me know. 😉

P.S., does it surprise you that fmt is in coreutils too? It shouldn’t.