[yunqa.de] Re: DIHtmlParser: Empty Attribute Problem

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx,<yunqa@xxxxxxxxxxxxx>
  • Date: Thu, 30 Jul 2009 14:39:35 +0200

At 14:53 30.07.2009, Mike Dixon wrote:

>I'm using DIHtmlParser and the CharCase and Writer plugin to simply convert
>an html page to lowercase before saving the file.
>
>My Problem is that when I have the following code:
>
><img src="foo.gif" alt="" />
>
>It is converted to:
>
><img src="foo.gif" alt/>
>
>Notice the ="" is missing from the output.
>
>I've tried setting DIHParser.TrimAttribValues := False; but that did not
>help.
>
>What am I missing?

Set the following properties of your TDIHtmlWriterPlugin instances:

  TDIHtmlWriterPlugin.EmptyHtmlAttribValues := True;
  TDIHtmlWriterPlugin.QuoteHtmlTags := qvAlways;

Btw: The automatic "conversion" was choosen because IMO an empty attribute 
value is equal to no attribute value in terms of HTML. Accordingly, the 
following two tags represent identical HTML:

  <img src=test.png alt="" />
  <img src=test.png alt />

I could not find the relevant section of the specification right now, but I 
checked that Firefox renders them exactly the same with explicitly "blank" 
alternative text. In this, they are different from

  <img src=test.png />

which is rendered with explicitly "missing" alternative text.

Ralf  

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: