jamietre / CsQuery

CsQuery is a complete CSS selector engine, HTML parser, and jQuery port for C# and .NET 4.
Other
1.16k stars 250 forks source link

CQ.CreateFromFile issue with html attributes with epmty values which are converting into unsupported formtat. #162

Open RajuA opened 10 years ago

RajuA commented 10 years ago

Hi, empty html attbutes are converting in to unsupported format Example:

<div itemscope="" itemtype="http://schema.org/Product" class="">

is parsed by csQuery as

<div itemscope itemtype="http://schema.org/Product" class>

which is causing problem in generating page markup in asp-net . Please help to fix this issue .

rufanov commented 9 years ago

Well, for HTML it's totally valid format.

It's standard behavior of RenderAttribute() method inside FormatDefault class. There is no setting to disable this, and you can't override this method, because it's protected, but not virtual(which is little strange). You can override RenderElementInternal() method to format attributes output differently. Or you can implement your own IOutputFormatter from scratch.