Re: [formatting html code]

by "Joshua Graham" <jagraham(at)ozemail.com.au>

 Date:  Fri, 26 Mar 1999 09:41:50 +1000
 To:  <hwg-software(at)hwg.org>
  todo: View Thread, Original
>I have to work with documents prepared by
>other people and sometimes I find it difficult
>to understand their code because of the way
>it is visally arranged on the page/screen.
>
>One person submitted files to me in which all the
>tags were lowercase and the html was just one
>long line! It was hell to work with until I
>reformatted it, which took quite a while.

I think Harold touched on this when he said, "If you are thinking about
~pretty print~ issues of making it most readable, such is very much a matter
of taste."

"Beautifiers" have been around a long time in the programming world. "Lint"
is one such popular tool for C programmers and that is why you'll see
references to "Lint-like" tools when talking about formatting a computer
language.

HTML has had some effort put into this area. The beautification involves
line breaking and indenting on tags that "make sense". Unfortunately, what
"makes sense" to one of us may "make mush" to another. Some tools have
configuration options to deal with this issue.

I've not used any PC-based HTML beautifier, I've only used them on Unix.

Nevertheless, to avoid your one-line file problem, try this.

When you get a text file that seems to be all on one line, it may have been
squeezed through a Unix system at some point. The end-of-line heuristics for
a default text file are slightly different on many platforms. Windows has a
new-line and a carriage-return character. Unix just has the new-line.

If the text file has originated on or been incorrectly transferred across a
Unix system, the carriage-return character is missing. Windows then thinks
it's a file with one long big line, although it has an uncommon number of
new-line characters in it! :-)

Many third-party text editors will interpret the file just fine. Also,
Microsoft Word handles them OK too. So, for example, fire up Word, open the
text file, and either Save As DOS text or copy and paste into Notepad, then
Save from there.

I'm sure we'll all do some research and list the beautification tools
available.

Regards,
Josh

HWG: hwg-software mailing list archives, maintained by Webmasters @ IWA