Re: How to Tidy Up HTML

3,002 views
Skip to first unread message

Tom Humiston

unread,
Jan 16, 2013, 8:35:56 PM1/16/13
to textwr...@googlegroups.com
I'm not an expert on this, but I know of at least one tool (with name remarkably close to your own wording): HTML Tidy. A search for "html tidy" turns up these links:

http://infohound.net/tidy/
This is an online version of HTML Tidy; the original is a command-line tool. This one's been around for several years and may not recognize HTML5 syntax.

http://www.dirtymarkup.com
Dirty Markup is also an online utility and looks sharp, though I haven't tried it. The developer says it supports HTML5. Probably the tool I'd use.

http://w3c.github.com/tidy-html5/
This command-line appears to be an update to the original Tidy. I don't know if there's a GUI version.

Usually I just rely on this manual routine: I left-align the code for all my block-level items, with minimal indents for LIs and TH/TDs. (In addition to find-and-replace, TextWrangler's Shift Left and Shift Right commands are handy for this.) In the case of closing tags that are separated from their opening tags by more than a few lines and might get lost or confused with another element of the same name, I put a comment directly in front of the closing tag, like so:
<div id=foo>
[multiple lines of content]
<!-- end foo --></div>


Cheers,
TH


On Jan 16, 2013, at 5:38 PM, madhi...@gmail.com wrote:

> I have searched the software, the help files, the manual and the internet and cannot seem to find what I thought was a simple thing: I want to clean up the general appearance of html pages. Shouldn't this be really easy? Please feel free to point out that the way to do this is right in front of my face. I am accustomed to that. :)

Thomas Fischer

unread,
Jan 17, 2013, 6:29:22 AM1/17/13
to textwr...@googlegroups.com
Hello,

I have a one-liner shell script in TextWrangler's Text Filters folder that I can invoke using a keyboard shortcut.
This uses xmllint, a Unix based utility for cleaning up and checking xml files.
My script follows below, if you want to use if for HTML files you will have to add --html as in:

XMLLINT_INDENT=$'\t' xmllint --format --html --encode utf-8 -

---------------------
#!/bin/sh

XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 -

# XMLLINT_INDENT=$'\t' : set indentation to "tab"
# xmllint : formate text
# - get STDIN
---------------------

Best
Thomas

Christopher Stone

unread,
Jan 17, 2013, 7:46:01 PM1/17/13
to textwr...@googlegroups.com
On Jan 17, 2013, at 18:09, madhi...@gmail.com wrote:
Did I misread the BBS website? It says:

Built-in Tidy support for code cleanup and accessibility checking - http://www.barebones.com/products/bbedit/comparison.html
______________________________________________________________________

That would be for BBEdit and NOT for TextWrangler.

--
Best Regards,
Chris



Rich Siegel

unread,
Jan 17, 2013, 7:47:08 PM1/17/13
to textwr...@googlegroups.com
On Thursday, January 17, 2013, madhi...@gmail.com wrote:

>Did I misread the BBS website? It says:
>
>Built-in Tidy support for code cleanup and accessibility checking -
>>http://www.barebones.com/products/bbedit/comparison.html

The section containing that item is part of the "Complete Set of
HTML Tools", which is exclusive to BBEdit. (In that chart,
sections highlighted in yellow are exclusive to BBEdit, and also
as such have a bullet in the right-hand column but not in the
left-hand column.)

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <http://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

Christopher Bort

unread,
Jan 17, 2013, 7:48:38 PM1/17/13
to textwr...@googlegroups.com
On 1/17/13 at 4:09 PM, madhi...@gmail.com wrote:

>Did I misread the BBS website?

Yes.

>It says:
>
>Built-in Tidy support for code cleanup and accessibility checking -
>>http://www.barebones.com/products/bbedit/comparison.html
>
>
>That is what I want to use, but I cannot find any instructions.

Note that the relevant row of the comparison chart indicates
that the features in it are present in BBEdit, but not in
TextWranger, BBE's free cousin. If you want the Tidy feature, or
any of the other features in the yellow rows of the chart, you
need to purchase a BBEdit license. Otherwise, with TextWrangler,
Thomas Fischer's solution is quick and easy. I don't set the
XMLLINT_INDENT environment variable to \t, as I prefer xmllint's
default indent of two spaces.

>On Wednesday, January 16, 2013 5:38:45 PM UTC-5, madhi...@gmail.com wrote:
>>
>>I have searched the software, the help files, the manual and
>>the internet and cannot seem to find what I thought was a
>>simple thing: I want to clean up the general appearance of
>>html pages. Shouldn't this be really easy? Please feel free to
>>point out that the way to do this is right in front of my
>>face. I am accustomed to that. :)
>
--
Christopher Bort
<top...@thehundredacre.net>

Reply all
Reply to author
Forward
0 new messages