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

V2 rule set declaration parsing #159

Merged
merged 6 commits into from
Jun 3, 2024

Conversation

stoivo
Copy link
Contributor

@stoivo stoivo commented May 29, 2024

I refactored expand_font_shorthand. I think its better. I think I want to do the same for all the other expand features. When I do that I think we can remove more of the regexes. Would you like that?

I am trying not to touch test too much to keep all existing features working.

Should I maybe add some notes into changelog that some features are removed?

@stoivo stoivo force-pushed the v2-rule-set-declaration-parsing branch from cb93ddc to 06acf7a Compare May 29, 2024 08:39
Comment on lines 10 to 14
# We have a Parser class which you create and instance of but we have some
# functions which is nice to have outside of this instance
module ParserFx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts on using self. methods for this ?
(just style so nbd, but it's what I would have expected)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking I could do that but I think the Parser class does so much already, and that class is public API so if I add a class method to Parser it public and open for use but I don't want that.

Also I am thinking we should maby change the public API to something like CssParser::Document.new, And on this instance we have method like add_block, load_url, each_rule, find_by_selector, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could make the methods private with private_class_method or class << self and private
ParserFx is also not private so kinda similar
if they are unrelated methods it's nice to get them out of the parser, but not sure they really are
ideally I'd want to keep the general structure the same so the upgrade instructions are just "replace method call a with b and change the args", but if you see a good reason then 👍 since it's v2 anyways

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also want to keep the structure the same so it's just upgrade and your good.

I need a way to share it with RuleSet instance so I don't think private class method is gooding to work

@@ -203,6 +203,85 @@ def expand_dimensions_shorthand! # :nodoc:
end
end

class FontScanner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 🎉

Copy link
Contributor

@grosser grosser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks really interesting :D

@stoivo stoivo force-pushed the v2-rule-set-declaration-parsing branch from 06acf7a to 38bb6ea Compare May 29, 2024 21:45
@stoivo
Copy link
Contributor Author

stoivo commented May 29, 2024

I need to investigate what happening here, never worked with Jruby before

@stoivo stoivo force-pushed the v2-rule-set-declaration-parsing branch 2 times, most recently from 2b26ea3 to fdf5cb2 Compare June 3, 2024 09:12
@stoivo
Copy link
Contributor Author

stoivo commented Jun 3, 2024

I don't know whats the matter with Jruby. Now it works with no change. Could be network issue
Screenshot 2024-06-03 at 11 14 42

Not you are running jruby-head(think this is master branch) I think you want jruby(latest release)?

@stoivo stoivo force-pushed the v2-rule-set-declaration-parsing branch 2 times, most recently from 38bb6ea to 57467b9 Compare June 3, 2024 09:31
I think this is a feature we can remove in v2. The consumer should strip
{} if they have them.

Added 13 years ago without much for a conversation
premailer#13
firefox will not evaluate declaration prop
`font: 300 italic auto/14px verdana, helvetica, sans-serif;` becase auto isn't valid
@stoivo stoivo force-pushed the v2-rule-set-declaration-parsing branch from 57467b9 to 2ce3d67 Compare June 3, 2024 09:35
@stoivo
Copy link
Contributor Author

stoivo commented Jun 3, 2024

I think we can merge this

@@ -14,6 +14,7 @@ Gem::Specification.new name, CssParser::VERSION do |s|
s.required_ruby_version = '>= 3.0'

s.metadata['changelog_uri'] = 'https://github.com/premailer/css_parser/blob/master/CHANGELOG.md'
s.metadata['documentation_uri'] = "https://www.rubydoc.info/gems/css_parser/#{s.version}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if this is still getting updated might be better to point to github

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets updated

@grosser grosser merged commit 3f6fd86 into premailer:v2 Jun 3, 2024
6 checks passed
@stoivo stoivo deleted the v2-rule-set-declaration-parsing branch June 4, 2024 06:26
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

Successfully merging this pull request may close these issues.

None yet

2 participants