Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Generating Indented HTML

1 view
Skip to first unread message

Pratibha

unread,
Nov 1, 2002, 10:14:27 PM11/1/02
to
What is the best/recommended technique for generating
indented output such as for HTML?

1. Use a global variable like *CURRENT-OUTPUT-COLUMN*
and define a macro to increment/decrement it
around a body of forms, and make every format
print *CURRENT-OUTPUT-COLUMN* spaces
on every line

2. Modify all your relevant functions to take a
current-column argument x, and when calling
any one of them from any one of them, pass x or
(+ x 2) as appropriate, and make every format
print x spaces on every line

3. Other technique?

When generating HTML, do you bother to indent at all?
It seems that doing so would it make it more
readable/editable/debuggable.

Adam Warner

unread,
Nov 2, 2002, 12:57:00 AM11/2/02
to
Hi Pratibha,

> When generating HTML, do you bother to indent at all?

No. I just put in some newlines at strategic places.

> It seems that doing so would it make it more
> readable/editable/debuggable.

If you always generate HTML there is no need to edit it. And the W3C's
validator does the debugging:

http://validator.w3.org/

And if you really need to view the nesting you can just run it through
HTML tidy with the indent option:

http://tidy.sourceforge.net/

-indent, -i
Indent contents of elements (by default using 2 spaces).

I think it's going too far having a single line of HTML. But newlines at
every paragraph, table, table row, etc. makes the HTML legible. Proper
nesting of all HTML could increase the file size significantly.

Debian.org's home page is 15,510 bytes. Run it through HTML tidy with the
indent option and it increases to 20,474 bytes.

Regards,
Adam

Erik Naggum

unread,
Nov 2, 2002, 7:40:14 AM11/2/02
to
* Pratibha

| When generating HTML, do you bother to indent at all?

No. I usually produce one long line, and I use &# a lot to avoid the
moronic parser of the moronic syntax of the moronic language. Producing
nice-looking HTML for people is like optimizing PostScript files for
legibility -- an utter waste of time.

| It seems that doing so would it make it more
| readable/editable/debuggable.

Do yourself a favor and read/edit/debug in a readable/editable/debuggable
language. HTML is not suitable for human consumption. Heck, it is not
even suitable for machine consumption.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.

Lars Magne Ingebrigtsen

unread,
Nov 2, 2002, 8:14:35 AM11/2/02
to
ibpra...@yahoo.com (Pratibha) writes:

> When generating HTML, do you bother to indent at all?
> It seems that doing so would it make it more
> readable/editable/debuggable.

That's true, but you should also consider the bandwidth usage. If
you're designing something for a web site that's going to be pumping
out your pages a lot, the indentation (if done "correctly") could
potentially represent a significant percentage of the bandwidth used.

That said, I try to generate "nice" HTML so that it's easy for others
to re-use bits they might take a fancy to.

--
(domestic pets only, the antidote for overdose, milk.)
la...@gnus.org * Lars Magne Ingebrigtsen

0 new messages