aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/HtmlParser.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/HtmlParser.c b/src/HtmlParser.c
index 90c1149..8972730 100644
--- a/src/HtmlParser.c
+++ b/src/HtmlParser.c
@@ -91,9 +91,10 @@ static void html_parser_reset(HtmlParser *self) {
self->attribute_value.size = 0;
self->text.data = NULL;
self->text.size = 0;
+ self->text_stripped.data = NULL;
+ self->text_stripped.size = 0;
self->is_tag_void = 0;
self->inside_script_tag = 0;
- self->pre_tag_depth = 0;
self->unclosed_tags_offset = 0;
}
@@ -274,8 +275,7 @@ static void html_parser_goto_script_end_tag(HtmlParser *self) {
html_parser_advance_char(self);
}
}
- if(self->text.size > 0)
- self->parse_callback(self, HTML_PARSE_JAVASCRIPT_CODE, self->callback_userdata);
+ self->parse_callback(self, HTML_PARSE_JAVASCRIPT_CODE, self->callback_userdata);
}
static void html_parser_goto_comment_end(HtmlParser *self) {
@@ -355,8 +355,6 @@ static void html_parser_parse_tag_start(HtmlParser *self) {
if(self->tag_name.size == 3 && memcmp(self->tag_name.data, "!--", 3) == 0) {
html_parser_goto_comment_end(self);
return;
- } else if(self->tag_name.size == 3 && memcmp(self->tag_name.data, "pre", 3) == 0) {
- ++self->pre_tag_depth;
}
self->is_tag_void = is_void_tag(&self->tag_name);
if(!self->is_tag_void) {
@@ -412,10 +410,6 @@ static void html_parser_parse_tag_end(HtmlParser *self) {
self->tag_name = self->unclosed_tags[self->unclosed_tags_offset - 1];
self->parse_callback(self, HTML_PARSE_TAG_END, self->callback_userdata);
}
-
- if(self->tag_name.size == 3 && memcmp(self->tag_name.data, "pre", 3) == 0) {
- --self->pre_tag_depth;
- }
} else {
fprintf(stderr, "Warning: start tag not found for end tag '%.*s'\n", (int)tag_end_name.size, tag_end_name.data);
}
@@ -450,10 +444,8 @@ void html_parser_parse(HtmlParser *self) {
html_parser_advance_char(self);
}
self->text.size = (self->source + self->offset) - self->text.data;
- if(self->pre_tag_depth == 0)
- strip(self->text.data, self->text.size, &self->text.data, &self->text.size, is_whitespace);
- if(self->text.size > 0)
- self->parse_callback(self, HTML_PARSE_TEXT, self->callback_userdata);
+ strip(self->text.data, self->text.size, &self->text_stripped.data, &self->text_stripped.size, is_whitespace);
+ self->parse_callback(self, HTML_PARSE_TEXT, self->callback_userdata);
}
}