[plt-scheme] Request for pretty-printing in webserver

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Apr 1 18:40:54 EST 2003

On Apr  1, MJ Ray wrote:
> Eli Barzilay <eli at barzilay.org> wrote:
> > [...] places where you space matters (eg <pre>), and places
> > where you want your output to look in a certain way (spaces or
> > newlines).  Also, it knows not to put spaces or newlines in the wrong
> > place -- right after an openning tag.
> Are you sure that you've done this correctly, Eli?  In general, it
> is safe to add additional whitespace to existing whitespace groups
> outside of certain tags, but not to add new whitespace groups.

I'm pretty sure...  That's roughly what happens anyway, for example:

  > (output-html
     (itemize: item> "foo" (b: "bar") item> (itemize: 1 2 3)))
    <li>foo <b>bar</b></li>

You can view my homepage sources (which are probably better looking
than the pages)...

> But that's only for html and the webserver generates XML in general.

Exactly, which is why I think it can be reused.

> Whitespace there may be significant depending on the styling, IIRC,
> so it's never safe to add whitespace without the programmer's
> approval.

But this is whitespace in the output which doesn't matter for the HTML
semantics, which should be pretty much automatic for easy viewing and
debugging.  If you want your specific style, then it is always
possible to override the defaults:

  > (output-html
     (itemize: item> "foo" (b: "bar")
               item> (itemize: ::newlines? #f 1 2 3)))
    <li>foo <b>bar</b></li>
    <li><ul><li>1</li> <li>2</li> <li>3</li></ul></li>

> In any case, is a pipe through a pretty printer when you want to
> debug so much effort

Yes -- to generate pretty output, you just do some more work on your
output routine.  To have a pp pipe, means that you need to parse the
html which is *much* more work.

> that it's worth doing more processing and using more network for all
> other cases?

Definitely -- in the world of non-programmers it is difficult to
convince people to use your tools, having a human readable and
editable output is important enough that some of the current users of
my thing would not use it otherwise.  As for bandwidth, did you ever
look sources made by commercial packages?  I once made an experiment,
getting a crap-free html from one made by frontpage, I don't remember
the numbers but that irrelevant crap was around 95% of the file size.
Also, I never use tabs myself -- but for that output I do use them.
The overall addition is negligible.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.