klacke@... wrote:
> > (patch file: mime_type.patch)
> >
>
> Excellent, applied.
Thanks
>
>
> This one I don't like that much though. The patch is way to slow
> to be applied. We can't do lists:member (+ construct a list
> of lists) for each tag we process.
>
That's OK, I've only been using Erlang for about 3-4 weeks now and
I'm still learning.
> But let's discuss the problem. Are you saying that all bodyless
> tags that are not in this EMPTY list must be /> terminated ?
>
No, I was wrong here (I knew I should have researched first,
where is my Brown bag ??).
The way it should be is that all elements in the list should
be terminated with ' />' (note the extra space).
> Looking at the code for ehtml_expand/1 there is now some
> special treatment for the <img> and the <br> tags, but I think
> that is more from an aesthetic point. (newlines inserted)
>
> Anyway, what exactly is the bug. Is it that for example:
>
> expand({input, [{type,submit}]})
>
> generates wrong HTML (without the enclosing </input>
>
> and that :
>
> expand({input, [{type,submit}],[]}) %% with an epty body
>
> is correct.
>
> If that is the case, the correct fix would be to insert
> function clauses like:
>
> ehtml_expand({input, Attrs}) -> ehtml_expand({input, Attrs,[]}) ->
>
No, input is an EMPTY element and should not have an end-tag. The fault
occured with :
expand({script, [{src, "somescript.js}]}).
And actually it is for compliance with XHTML (and not HTML 4.0), but it
seems that IE wants this behaviour (it works without the patch in
Mozilla).
So concluding:
In XHTML (and not HTML 4.0x as indicated in the patch) all elements
should have a closing tag except EMPTY elements.
Those should use a shorthand notation: <tag attrs /> (with a space before
the '/' to allow for backward compatibility).
Here are some references:
http://www.w3.org/TR/xhtml1/#h-4.3
http://www.w3.org/TR/xhtml1/#h-4.6
http://www.w3.org/TR/xhtml1/#guidelines
So a better(?) patch might be:
%% no end-tag allowed for these elements
ehtml_expand({area, Attrs}) -> ["\n<area", ehtml_attrs(Attrs), " />"];
ehtml_expand({base, Attrs}) -> ["\n<base", ehtml_attrs(Attrs), " />"];
ehtml_expand({basefont, Attrs}) -> ["\n<basefont", ehtml_attrs(Attrs), " />"];
ehtml_expand({br, Attrs}) -> ["<br", ehtml_attrs(Attrs), " />"];
ehtml_expand({col, Attrs}) -> ["\n<col", ehtml_attrs(Attrs), " />"];
ehtml_expand({frame, Attrs}) -> ["\n<frame", ehtml_attrs(Attrs), " />"];
ehtml_expand({hr, Attrs}) -> ["\n<hr", ehtml_attrs(Attrs), " />"];
ehtml_expand({img, Attrs}) -> ["<img", ehtml_attrs(Attrs), " />"];
ehtml_expand({input, Attrs}) -> ["\n<input", ehtml_attrs(Attrs), " />"];
ehtml_expand({isindex, Attrs}) -> ["\n<isindex", ehtml_attrs(Attrs), " />"];
ehtml_expand({link, Attrs}) -> ["\n<link", ehtml_attrs(Attrs), " />"];
ehtml_expand({meta, Attrs}) -> ["\n<meta", ehtml_attrs(Attrs), " />"];
ehtml_expand({param, Attrs}) -> ["\n<param", ehtml_attrs(Attrs), " />"];
%% make sure there is an end tag for elements without content
ehtml_expand({Tag, Attrs}) -> ehtml_expand({Tag, Attrs,[]});
Tested this with NS 4.76, Mozilla 1.4, IE 5.xx
Regards
/Rob
PS I subscribed to the list now, and the archives are back.
|