[plt-scheme] Re: pretty html source
Eli wrote:
> Dave wrote:
>> I'm definitely considering building [HTML pretty printing] into
>> Mirrors. [...]
>
> That's much more difficult than it sounds... It's easy to do
> something simple -- actually, the xml collection *can* print stuff
> with indentation:
>
> (display-xml/content (xexpr->xml '(p (ul (li "foo") (li "bar")))))
>
> but it doesn't take into account places where you shouldn't add
> whitespaces (like after "<li>" and before "</li>" in that example)
> [...]
Oh absolutely. The "simple" version I was referring to was a naive one
you suggested above.
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.
-- Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20081114/e27a8bb8/attachment.html>