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

feat: add wildcard * class to ignore classes when matching parent elements #309

Closed

Conversation

hmnd
Copy link

@hmnd hmnd commented Jan 19, 2022

Fixes #308 by introducing a wildcard class selector for html paths. When a wildcard is used, a new element option ignoreClass is enabled which bypasses checking attribute equality in Element.prototype.matchesElement.
I'm new to lop, so I know the rule I've setup has a hole which would count * as a regular class if * is used in conjunction with another class. Would appreciate some guidance on how I would go about preventing that.

Thanks for this awesome project!

@hmnd
Copy link
Author

hmnd commented Jan 21, 2022

For others looking for a solution to this before it gets merged (hopefully), I've published the PR as @icewolf/mammoth@1.4.20-bleeding.0.

@mwilliamson
Copy link
Owner

Hmm, I'm not sure about the syntax. Ideally we'd do something similar to CSS, although I'm not sure there's any syntax that would actually cover this (since the existing matchers require an exact match, whereas CSS selectors allow extra attributes/classes).

An alternative might be something like p:ignore-class or p:ignore(class) (where the latter in principle allows other attributes to be ignored, not that you can set other attributes at the moment).

@mwilliamson
Copy link
Owner

Closing due to inactivity. If anybody wants to keep discussing it, please do so on #308.

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.

Allow ignoring class when finding parent elements that satisfy html path
2 participants