js-beautify icon indicating copy to clipboard operation
js-beautify copied to clipboard

`include+` and `include-` properties

Open alexreg opened this issue 5 years ago • 4 comments

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" ] }

alexreg avatar Apr 28 '19 19:04 alexreg