Make self-closing tags errors
This commit is contained in:
parent
4b740c23df
commit
acbd843aa2
|
@ -96,6 +96,10 @@ See [voidtags.c](src/main/c/rule/tag/voidtags.c) for the list of tags considered
|
|||
|
||||
This includes tags that close automatically because of siblings (e.g. `<li><li>`), as it greatly simplifies the complexity of the minifier due to guarantees about the structure.
|
||||
|
||||
#### `HBE_PARSE_SELF_CLOSING_TAG`
|
||||
|
||||
It's an error if a tag is self-closed. Valid in XML, not in HTML.
|
||||
|
||||
#### `HBE_PARSE_UNEXPECTED_END` and `HBE_PARSE_EXPECTED_NOT_FOUND`
|
||||
|
||||
General syntax errors.
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef enum hbe_errcode {
|
|||
HBE_PARSE_UNQUOTED_ATTR,
|
||||
HBE_PARSE_ILLEGAL_CHILD,
|
||||
HBE_PARSE_UNCLOSED_TAG,
|
||||
HBE_PARSE_SELF_CLOSING_TAG,
|
||||
|
||||
HBE_PARSE_UNEXPECTED_END,
|
||||
HBE_PARSE_EXPECTED_NOT_FOUND,
|
||||
|
|
|
@ -100,6 +100,8 @@ static void _parse_and_add_errors_to_suppress(nh_set_int32_t suppressed_errors,
|
|||
nh_set_int32_add(suppressed_errors, HBE_PARSE_UCASE_TAG);
|
||||
} else if (hbu_buffer_compare_lit(part, "UNQUOTED_ATTR") == 0) {
|
||||
nh_set_int32_add(suppressed_errors, HBE_PARSE_UNQUOTED_ATTR);
|
||||
} else if (hbu_buffer_compare_lit(part, "SELF_CLOSING_TAG") == 0) {
|
||||
nh_set_int32_add(suppressed_errors, HBE_PARSE_SELF_CLOSING_TAG);
|
||||
} else {
|
||||
hbe_fatal(HBE_CLI_INVALID_SUPPRESSABLE_ERROR, "Unrecognised suppressable error `%s`", hbu_buffer_underlying(part));
|
||||
}
|
||||
|
@ -125,11 +127,11 @@ int main(int argc, char **argv) {
|
|||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"input", required_argument, NULL, 'i'},
|
||||
{"output", required_argument, NULL, 'o'},
|
||||
{"suppress", optional_argument, NULL, 's'},
|
||||
{"suppress", required_argument, NULL, 's'},
|
||||
|
||||
{"MXcollapseWhitespace", optional_argument, NULL, 1},
|
||||
{"MXdestroyWholeWhitespace", optional_argument, NULL, 2},
|
||||
{"MXtrimWhitespace", optional_argument, NULL, 3},
|
||||
{"MXcollapseWhitespace", required_argument, NULL, 1},
|
||||
{"MXdestroyWholeWhitespace", required_argument, NULL, 2},
|
||||
{"MXtrimWhitespace", required_argument, NULL, 3},
|
||||
|
||||
{"MXtrimClassAttr", no_argument, &(config_stream->trim_class_attr), 0},
|
||||
{"MXdecEnt", no_argument, &(config_stream->decode_entities), 0},
|
||||
|
|
|
@ -33,7 +33,10 @@ void hbs_tag(hbs_options_t so, hbu_pipe_t pipe) {
|
|||
}
|
||||
|
||||
if (hbu_pipe_accept_if_matches(pipe, "/>")) {
|
||||
hbu_pipe_warn(pipe, "Self-closing tag");
|
||||
if (!hbs_options_supressed_error(so, HBE_PARSE_SELF_CLOSING_TAG)) {
|
||||
hbu_pipe_error(pipe, HBE_PARSE_SELF_CLOSING_TAG, "Self-closing tag");
|
||||
// Unreachable
|
||||
}
|
||||
self_closing = 1;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue