Skip to content

Keep comments in CssStyleSheet #99

Open
@mganss

Description

@mganss

It seems that CSS comments are not kept in the CSSOM and thus are not preserved when you call ToCss() on a previously parsed CssStyleSheet object.

var html = @"<style>  /* Set text color to red */ h1{color:red}</style>";
var parser = new HtmlParser(new HtmlParserOptions(), BrowsingContext.New(Configuration.Default.WithCss(new CssParserOptions())));
var dom = parser.ParseDocument(html);
var styleSheet = dom.StyleSheets[0] as ICssStyleSheet;
var css = styleSheet.ToCss(); // -> "h1 { color: rgba(255, 0, 0, 1) }"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions