-
-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Description
Prerequisites
- Can you reproduce the problem in a MWE?
- Are you running the latest version of AngleSharp.Css?
- Did you check the FAQs to see if that helps you?
- Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g.,
AngleSharp.Xmlfor Xml support) - Did you perform a search in the issues?
Description
a
{
text-decoration: none;
}
will generate invalid css:
{
text-decoration: none;
}
Steps to Reproduce
using AngleSharp;
using AngleSharp.Css;
using AngleSharp.Css.Parser;
namespace AngleSharpCssBugReport
{
internal class Program
{
static string cssString = @"img
{
max-height: 98%;
max-width: 100%;
}
a
{
text-decoration: none;
}";
private static readonly CssParserOptions CssParserOptions = new()
{
IsIncludingUnknownDeclarations = true,
IsIncludingUnknownRules = true,
IsToleratingInvalidSelectors = true
};
static void Main(string[] args)
{
Console.WriteLine("AngleSharp Version:" + typeof(AngleSharp.BrowsingContext).Assembly.GetName().Version);
Console.WriteLine("AngleSharp.CSS Version:"+ typeof(CssParser).Assembly.GetName().Version);
Console.WriteLine("Original CSS:");
Console.Write(cssString);
Console.WriteLine();
var cssParser = new CssParser(CssParserOptions);
var stylesheet = cssParser.ParseStyleSheet(cssString);
var stringWriter = new StringWriter();
IStyleFormatter formatter = new PrettyStyleFormatter();
stylesheet.ToCss(stringWriter, formatter);
Console.WriteLine("Processed CSS:");
Console.Write(stringWriter.ToString());
Console.WriteLine();
}
}
}
<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.3.1-beta.491" />
<PackageReference Include="AngleSharp.Css" Version="1.0.0-beta.157" />
</ItemGroup>
Expected Behavior
should generate valid css for a tag
Actual Behavior
generate empty selector
AngleSharp Version:1.3.1.0
AngleSharp.CSS Version:1.0.0.0
Original CSS:
img
{
max-height: 98%;
max-width: 100%;
}
a
{
text-decoration: none;
}
Processed CSS:
img {
max-height: 98%;
max-width: 100%;
}
{
text-decoration: none;
}
Possible Solution / Known Workarounds
don't know