[plt-scheme] Re: pretty html source
On Nov 14, Dave Gurnell wrote:
>
> Oh absolutely. The "simple" version I was referring to was a naive
> one you suggested above.
FWIW, the code that I used would do something like this with the
previous example:
<p><ul> ; no space after the <p>, but the next line
<li>blah</li> ; has four spaces because it's two levels
<li>blah</li> ; in
</ul></p>
This means that for each html tag I need to keep information about
whether whitespace being ignored (for example, <ul>), not ignored
(<li> and <p>), or "very not ignored" as in <pre>. It was a mess, and
definitely too much work for too little profit.
> I was previously content to rely on pretty-printing plugins for
> Firefox to do my formatting for me (the "View Source Chart"
> extension is quite good). I'm really impressed with PPrint, though,
> so now I'm now tempted to give some full-featured Scheme code a try.
>
> Come to think of it (and as an aside), there *is* a reason I haven't
> put pretty printing into Mirrors yet... the compile-time rendering
> features make it difficult to do. By default, something like:
>
> (xml (p "Hi " (b ,name)))
>
> is macro-transformed to the equivalent of:
>
> (xml (!raw "<p>Hi <b>") ,name (!raw "</b></p>"))
>
> This feature can be turned off but !raw blocks are always available
> to the programmer and it's not obvious now to handle them in pretty
> printed output. Suggestions welcome.
Looks like you'll have to translate that to raw strings that will
appear one line, with a `break' tokens that carry the indentation
level that they must go in. That's for the "simple approach"; for the
real pprint way you'll probably need to add soft and hard breaks, and
probably even breaks at different levels of soft/hard.
So my opinion is that this is even more work for an even less gain
(since it's even less likely that someone will take generated pages
and edit them). The only utility I can see in this is debugging --
and things like browser view of the xml tree or a dom inspector are
much better at doing these things anyway.
(And that's really pointing at the ridiculousness of the xml syntax
with its "human readable" redundancy -- it's only a question of time
until no manually-written html pages exist.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!