Skip to content

Keep comments in CssStyleSheet #99

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) }"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions