Tag Archives: clean

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. 😀

xmlstarlet: A superstar for XML

xidel was kind to me, reducing much of my boiling invective for XML configuration files to a rolling simmer aimed at the inconvenience. xmlstarlet has the potential to cool that simmer to a lukewarm distaste.


Now neither tool alone will ever quench my hatred, and together I doubt very much they’d be able to do more than keep my day from turning black. But K.Mandla is definitely mellowing out.

xmlstarlet is a collection of tools for formatting, polling, editing and transforming XML files. That alone is only a sliver of what it can do, and in the right hands it would no doubt be quite a weapon.

For us mere mortals, it’s nice to be able to reformat files and get their components nested cleanly, or to see the breakdown between elements, or just validate them to make sure they’re not broken. (That’s the worst, a broken XML configuration file. I writhe just to think about it.)

But xmlstarlet can apparently also count the number of elements matching an expression, trickle through an XML document and total up specific elements and output to a table, and if you’re lucky, even make a list of links embedded in an XHTML file. Take a look at the documentation if you don’t believe me.

Little people like me, who never have an occasion to work with XML other than my .config/openbox/rc.xml file, will find the most basic xmlstarlet tricks to be sufficient reason to keep it around. “It can clean up my menu.xml file? Please, please, please!”

On the other hand, that’s just a tiny taste of what xmlstarlet can do, and a brief spin past the documentation will make that abundantly clear. Make sure you take a close look at this one before you move to the next tool du jour. You’ll be missing out otherwise. 😉

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. 😉

csvkit: Lots of little tools, in a pack

I don’t work with csv files much, but I hear they are popular among those who use databases.

I have run through one or two, for example when converting from sc format to csv, for access through conventional graphical spreadsheets. That requires a little search-and-replace acrobatics, as you might expect. To that end, csvkit has some nifty tools in it.


csvclean can touch up small errors in a csv file. csvlook displays the contents in a table format, drawn with a header and ASCII lines.

csvstat can give you a breakdown of each column in a csv file, and there are csvcut, csvgrep, csvsort, csvjoin … among still others.

It seems that most of the tools have some unified flags and options; for example, the flag to declare a different delimiter in csvlook is the save in csvstat. Uniformity: That’s a good idea.

There are enough tools in here to keep the maddest scientist busy for a while, and I doubt it would take long to adopt them. If you work with csv files a lot, this might be the tool you’ve been waiting for. 😉

cleanlinks: Use with caution

Here’s an odd little utility for you: Buried deep in the Xorg imake tool is cleanlinks.

No screenshot this time. Nothing to show. And also because … I’m afraid to use it. 😳

See, cleanlinks starts at your $PWD and skims through subdirectories, looking for empty folders and dead symlinks … and then deletes them.

With no warnings, and no interaction, and no confirmation. Just a list of the recently deceased. 😯

First time I tried cleanlinks I panicked because three or four local directories disappeared.

Technically speaking they were empty, so yes they should have been removed. They were just static directories that I keep around for structure’s sake. Like “hold” or “temp” or “downloads”. 🙄

So no major damage was done. Then I checked the man page, and realized it was a rather arbitrary tool. Not even a help flag.

So by all means, use it to clean out content-less folders and link-less links. Just be aware that it will do exactly what it promises … without checking for your permission. 😐

P.S., Debian users can find this in xutils-dev.