Open alexreg opened 5 years ago
@alexreg
Thanks for filing this.
This can be done, but it will probably be difficult and error prone until after the beautifier does a much better job of parsing. The html beautifier only recently reached the point of parsing tokens before beautifying. Before that it would have been impossible to even do a ul.classA
query, let alone ul.classA > li
.
Allowing some query notation in the existing inline
setting would be preferable IMO - that would allow us to keep the behavior well defined and keep us from having to lock down APIs that are currently internal and in-progress. Implementing some querying would be involved but would be less of a bug farm than taking a function.
It would be very useful to be able to specify a function to the options that would take 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 exampleul.classA > li
elements (to use CSS notation). Adding support for such CSS/jQuery notation to the existinginclude
family of properties is an alternative solution.cf. https://github.com/beautify-web/js-beautify/issues/1668