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

Expose start and end token for simple_rule, needed for sourcemaps #19

Open
stoivo opened this issue May 24, 2024 · 3 comments
Open

Expose start and end token for simple_rule, needed for sourcemaps #19

stoivo opened this issue May 24, 2024 · 3 comments

Comments

@stoivo
Copy link
Contributor

stoivo commented May 24, 2024

I think it would be good to add two more values to style_rule node. block_start amd block_end

css = <<~CSS
body {font-size:small;}
CSS
# body {font-size:small;}
# 01234567891111111111222
#           0123456789012

pp tree = Crass.parse(css, :preserve_comments => false)
[{:node=>:style_rule,
  :selector=>
   {:node=>:selector,
    :value=>"body",
    :tokens=>
     [{:node=>:ident, :pos=>0, :raw=>"body", :value=>"body"},
      {:node=>:whitespace, :pos=>4, :raw=>" "}]},
  :children=>
   [{:node=>:property,
     :name=>"font-size",
     :value=>"small",
     :children=>
      [{:node=>:ident, :pos=>16, :raw=>"small", :value=>"small"}],
     :important=>false,
     :tokens=>
      [{:node=>:ident,
        :pos=>6,
        :raw=>"font-size",
        :value=>"font-size"},
       {:node=>:colon, :pos=>15, :raw=>":"},
       {:node=>:ident, :pos=>16, :raw=>"small", :value=>"small"}]},
    {:node=>:semicolon, :pos=>21, :raw=>";"}]},
 {:node=>:whitespace, :pos=>23, :raw=>"\n"}]
@stoivo
Copy link
Contributor Author

stoivo commented May 24, 2024

One option might be to expose tokens

@flavorjones
Copy link
Contributor

@stoivo Can you explain about about the use case, to help readers understand why you're asking for this feature?

@stoivo
Copy link
Contributor Author

stoivo commented May 27, 2024

Yes, I just briefly mention it in the title. Good to expand on that. I am working on refactoring css_parser. One of the features is to see where the rules are defined. Something like source maps for css and javascript.

Does that explain it?

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

2 participants