-
Notifications
You must be signed in to change notification settings - Fork 23
Get index of node within source string #12
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
Comments
@jeddy3 Do you mean position start? |
Yep. I think so. So given a value of: red, rgba(0, 0, 0, 0); You'll get something like nodes: [
type: 'function',
value: 'rgba',
before: "",
after: "",
sourceIndex: 5 // the start position of the `rgba` in the original value string Although, now I'm wondering if I misunderstood our needs. I'm going to ask for @davidtheclark advice on this. @davidtheclark I'm working on So given a {
background-image:
linear-gradient(45deg, blue, red),
linear-gradient(90deg, black, white);
} Am I right in thinking I'm after the start position of the two function names within the value string? And this is something we're hoping to get from the value parser? |
Yes, @jeddy3: That link to the postcss-selector-parser feature is dead on: that's what we need for a completely accurate position. |
Thanks for the clarification @davidtheclark . @TrySound Do you think it'll be possible? |
@jeddy3 Yep, I'll do that. |
Thank you :) |
@jeddy3 @davidtheclark Do you expect sourceIndex in div since space before or div char? |
That's a good question. I've not used the |
Since |
@ben-eb You mean 4? :) |
|
@ben-eb posDiv - before.length ? |
Whoops. I meant 4. 😄 |
Wait ... in the |
Nevertheless ... I reviewed a bunch of the tests in the PR https://github.com/TrySound/postcss-value-parser/pull/17/files and they all made sense/seemed right to me, so maybe I'm just missing something here. |
@davidtheclark It takes also the space before which is start of the node { type: 'div', sourceIndex: 4, value: ',', before: ' ', after: '' } |
👍 |
Would it be possible to support getting the string-index of a node within its source string? Similar to how
postcss-selector-parser
does it.The use-case is for stylelint, to feed these indexes into PostCSS 5's new warning index option, in order to get accurate positions for errors.
The text was updated successfully, but these errors were encountered: