Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP: Added additional arg for turning styles into properties #139
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
base: master
Are you sure you want to change the base?
WIP: Added additional arg for turning styles into properties #139
Changes from 6 commits
209036e
8a2a072
cb4dd0b
8f75d56
7a9c350
8d61dc4
0959ecc
1b9bc34
3365a79
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we'd have a similar situation to the branchs below:
styles
(similar to line 319) and callattributes.insert
with rule name / value.attributes
, merged with collected styles, and then those "final" styles should be inserted intoattributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so within the conditional branch I created, we will have 2 conditional branches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so I think I got the first bullet point completed, I'm not quite sure if I understand the second one yet, but it's also a bit late for me haha. Will take a look tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I think we can use
attribute.remove
straight away instead ofget_mut
(it returns Option), so the output doesn't have the "style" attribute.For the second point, the workflow would look like the other branch with
attributes.insert
, but the existing "style" value should be merged together with ones collected from "style" tags (or other places).At the moment,
merge_styles
outputsResult<String>
which is not exactly what is needed. Instead, there could be a new function that will insert new attributes intoattributes
instead of pushing them to a string.Something like this
And the last branch would look like this:
I didn't test these code samples, but they should be alright :) The main idea is that existing "style" attribute styles are inserted as separate attributes immediately as they have the maximum priority, then the other ones are inserted only if they aren't clashing with already inserted ones.
Then, there is a small corner case with quoting the value (see the
replace_double_quotes
macro). Before inserting, each property name & value should be checked:which could be also a small macro (the naming probably isn't much important - maybe
insert_unquoted
?)Then, I think a few tests would be nice to have :) And a changelog entry