chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Minor issue with spiffy's sxml->html


From: Peter Wright
Subject: Re: [Chicken-users] Minor issue with spiffy's sxml->html
Date: Sat, 30 Dec 2006 01:07:26 +0900
User-agent: Mutt/1.5.13 (2006-08-11)

On 29/12 00:55:50, felix winkelmann wrote:
> On 12/28/06, Peter Bex <address@hidden> wrote:
> >On Thu, Dec 28, 2006 at 11:45:00PM +0900, Peter Wright wrote:
> >> After testing it a bit, it looks like any HTML generated via
> >> sxml->html will have all close tag(s) followed by end-of-line
> >> character(s).
> >>
> >> Does anyone know of a way to disable this behaviour?
[ ... ]
> >The SXML->HTML in spiffy is a hack.  You probably want the
> >SXML->HTML functionality from the sxml-transforms egg.  Why
> >SXML->HTML was reimplemented in Spiffy, I do not know.  Felix?
> 
> Can't remember, unfortunately, but likely to remove dependencies.
[ ... ]
> I have uploaded a new version of spifffy (2.39) that does it the way
> sxml-transforms do it (thanks, Zbigniew, for the suggestion, BTW).
> I also renamed "sxml->html" to "write-sxml" (but kept the old name
> for backwards compatibility).
> 
> Peter (Wright): could you try the currently available spiffy?

Yep, tried it. It works fine re: the specific problem I had with the
earlier version (thanks), but the sxml-transforms version (which I
hadn't previously noticed) seems to work a little better... for some
value of "better". :-)

Using the new spiffy (2.39):

------------------------ tryit.scm ------------------------ 
#!/usr/local/bin/csi -script
(use spiffy sxml-transforms)

(define test-sxml
  '(html
     (head
       (title "Title")
       (body (h1 "Heading")
             (quack "This sentence should end "
                    (moo (@ (href "http://google.com/";)) "with a link")
                    ".")
             (p "This sentence should end "
                (a (@ (href "http://google.com/";)) "with a link")
                ".")))))
(begin
  (display "*** testing write-sxml...\n")
  (write-sxml test-sxml)
  (newline)
  (display "*** testing SXML->HTML...\n")
  (SXML->HTML test-sxml)
  (newline))
------------------------ tryit.scm ------------------------ 

...produces:

------------------------ test ------------------------ 
~/src/scheme/chicken $ ./tryit.scm
*** testing write-sxml...

<html>
<head>
<title>Title</title>
<body>
<h1>Heading</h1>
<quack>This sentence should end
<moo href="http://google.com/";>with a link</moo>.</quack>
<p>This sentence should end
<a href="http://google.com/";>with a link</a>.</p></body></head></html>
*** testing SXML->HTML...

<html>
<head>
<title>Title</title>
<body>
<h1>Heading</h1>
<quack>This sentence should end
<moo href="http://google.com/";>with a link</moo>.</quack>
<p>This sentence should end <a href="http://google.com/";>with a 
link</a>.</p></body></head></html>
~/src/scheme/chicken $
------------------------ test ------------------------ 


The difference appears to be that the SXML->HTML treats the <a> tag
specially - it doesn't seem to have a leading line-break. But all
other tags (including the nonsense tags <moo> and <quack>) seem fairly
consistent in having a line-break just before the opening.

I'm guessing SXML->HTML has a special-case handling for the standard
"inline"-display HTML tags (see
http://www.webdesignfromscratch.com/css-block-and-inline.cfm ).
After a quick verification check, it appears that it handles <b> and
<i> the same way.

I suspect it's only the inline tags for which a stray line-break could
make a difference in a browser's rendering, which would explain the
special handling.

> cheers,
> felix

Thanks for the helpful hints, all (and the spiffy patch, Felix).
Much appreciated.

Pete.
-- 
http://flooble.net/blog
"Debugging or reading Unlambda programs is just about impossible."
    -- Unlambda: Your Functional Programming Language Nightmares Come True




reply via email to

[Prev in Thread] Current Thread [Next in Thread]