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

include+ and include- properties #1668

Open
alexreg opened this issue Apr 28, 2019 · 4 comments
Open

include+ and include- properties #1668

alexreg opened this issue Apr 28, 2019 · 4 comments

Comments

@alexreg
Copy link

alexreg commented Apr 28, 2019

Description

I propose the addition of include+ and include- properties in the configuration options, which respectively add and remove items from the include list. At the moment, only the entire list can be replaced/redefined, which is quite unergonomic and does not compose well with presets, etc.

Bonus

It would be very useful to be able to specify a function to the option that takes an HTML node object as a parameter, and returns a boolean value to specify whether the element should be beautified (or conversely, whether it should be considered inline). Returning "undefined" would fall back to the static include/include+/include- properties in options. This feature would allow you to only inline for example ul.classA > li elements (to use CSS notation). Adding support for such CSS/jQuery notation to the existing include family of properties is an alternative solution.

Input

With this new feature, I expect this configuration:

"inline+": [ "li" ]

to be equivalent to:

"inline": [ "a", "abbr", "area", "audio", "b", "bdi", "bdo", "br", "button", "canvas", "cite", "code", "data", "datalist", "del", "dfn", "em", "embed", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "map", "mark", "math", "meter", "noscript", "object", "output", "progress", "q", "ruby", "s", "samp", "select", "small", "span", "strong", "sub", "sup", "svg", "template", "textarea", "time", "u", "var", "video", "wbr", "text", "acronym", "big", "strike", "tt", "li" ] }

Likewise, I expect this configuration:

"inline-": [ "a" ]

to be equivalent to:

"inline": [ "abbr", "area", "audio", "b", "bdi", "bdo", "br", "button", "canvas", "cite", "code", "data", "datalist", "del", "dfn", "em", "embed", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "map", "mark", "math", "meter", "noscript", "object", "output", "progress", "q", "ruby", "s", "samp", "select", "small", "span", "strong", "sub", "sup", "svg", "template", "textarea", "time", "u", "var", "video", "wbr", "text", "acronym", "big", "strike", "tt" ] }
@bitwiseman
Copy link
Member

Thanks @alexreg. Due to the way CLI options are parsed, this might need to be implemented as:

"inline": [ "+", "li" ]

And

"inline": [ "-", "a" ]

@alexreg
Copy link
Author

alexreg commented Apr 29, 2019

@bitwiseman Sure. I mean, that's slightly less intuitive, but if it makes the implementation a lot easier, then sounds fair. Does the bonus feature (in either form) sound doable to you too?

@bitwiseman
Copy link
Member

bitwiseman commented Apr 29, 2019

@alexreg
Re Bonus feature:
It is possible, but it definitely won't be implemented as part if this feature.
Also, to be clear, it is unlikely I'll have time to implement it - it would need someone else to take ownership of it.
Please open a new issue and we can discuss it there.

@bitwiseman
Copy link
Member

Implementation would probably go in these two methods:

In

If we went with the "inline": [ "+", "li" ] syntax, those methods would need to look at the first element in the array to determine if it was an add or subtract case instead of the default set case.

As an alternative, those methods could look for option named <optionName> and if not found take the default. Then look for <optionName>-add followed by <optionName>-rm and process those on top of the current value. Then return.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants