erlyaws / yaws

Yaws webserver
https://erlyaws.github.io
BSD 3-Clause "New" or "Revised" License
1.28k stars 268 forks source link

ehtml may not generate valid HTML #57

Closed Ummon closed 12 years ago

Ummon commented 13 years ago

Markup without content do not generate a well formed HTML. For example {img, [{src, "img/foo.png"}]} will be translated to <img src="img/foo.png"></img> instead of <img src="img/foo.png" />.

W3C example: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.d-lan.net%2Fdonate.html&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.2 source: https://github.com/Ummon/D-LAN/blob/2a114f46a09f063c22aee5f20765049789c670ef/yssi/donate.yaws

I don't think it costs to much to change this behavior.

Yaws version I use: 1.88

vinoski commented 13 years ago

Yes, this is an issue. We had a discussion on the list awhile back that's somewhat related to this; it was about differences between HTML versions that ehtml should be able to handle. The img tag, for example, has no closing tag in HTML but does in XHTML. I know how to fix it but have just never gotten to it.

Ummon commented 13 years ago

But <img src=".." /> is both valid in XHTML and HTML!? So why do not use this notation?

vinoski commented 13 years ago

The img tag is just one example of differences between various HTML versions. To address this properly means

As I said, I know how to do all this. I just haven't gotten a chance to work on it yet.

Ummon commented 13 years ago

OK, thanks for your comments (and all your work), I will be patient ;)

klacke commented 13 years ago

On 05/18/2011 08:32 PM, Ummon wrote:

Markup without content do not generate a well formed HTML. For example {img, [{src, "img/foo.png"}]} will be translated to instead of.

W3C example: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.d-lan.net%2Fdonate.html&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.2 source: https://github.com/Ummon/D-LAN/blob/2a114f46a09f063c22aee5f20765049789c670ef/yssi/donate.yaws

I don't think it costs to much to change this behavior.

Yaws version I use: 1.88

Hmmmm.. this has been up for discussion many times. I don't exactly recall what the snag was, but there was indeed a snag.

If you post to the erlang list, I'm sure someone recalls, or if you search the archives ....

/klacke

klacke commented 12 years ago

The new exhtml mode is the solution. New return value from out/1

{exhtml, Struct}

produces proper strict xhtml

Ummon commented 12 years ago

Great, thank you :D