Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing comments #36

Open
jsmarkus opened this issue Feb 27, 2012 · 4 comments
Open

Parsing comments #36

jsmarkus opened this issue Feb 27, 2012 · 4 comments

Comments

@jsmarkus
Copy link

I am going to use your parser for CSS sprites generator.

It would be convenient to parse comments as properties annotations like in the following example:

.icon {
background-image: url(./arrow.png); /*sprite: spr1.png*/
width: 24px;
height: 24px;
}
{
    parentStyleSheet: null,
    cssRules: [
        {
            parentRule: null,
            parentStyleSheet: "../..",
            selectorText: ".icon",
            style: {
                0: "background-image",
                1: "width",
                2: "height",
                length: 3,
                parentRule: "..",
                _importants: {
                    "background-image": "",
                    width: "",
                    height: ""
                },
                _comments: {
                    "background-image": "sprite: spr1.png",
                },
                __starts: 6,
                "background-image": "url(./arraw.png)",
                width: "24px",
                height: "24px"
            },
            __starts: 0,
            __ends: 93
        }
    ]
}
@NV
Copy link
Owner

NV commented Feb 28, 2012

I have a not yet released fork of CSSOM that does it like this:

{
    cssRules: [
        {
            selectorText: ".icon",
            properties: [
                {
                    name: "background-image",
                    value: "url(./arrow.png)",
                    important: false,
                    original: "\nbackground-image: url(./arrow.png); /*sprite: spr1.png*/\n"
                },
                {
                    name: "width",
                    value: "24px",
                    important: false,
                    original: "width: 24px;\n"
                }
            ],
            originalSelector: ".icon ",
            originalAppendix: ""
        }
    ]
}

@jsmarkus
Copy link
Author

jsmarkus commented Mar 5, 2012

It's almost what i expected to see in CSSOM. It would really help me. Thanking you in anticipation!

@papandreou
Copy link
Contributor

@jsmarkus I've done something very similar here: https://github.com/One-com/assetgraph-sprite -- except that I put the spriting instructions into vendor-prefixed CSS properties. That actually turned out to be very pleasant to work with because it's valid CSS.

@zakdances
Copy link

@NV If you don't want to merge this into master, can you push this as a separate branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants