|
4 | 4 | #include "../../include/analyze/action_view/tag_helper_node_builders.h" |
5 | 5 | #include "../../include/analyze/analyze.h" |
6 | 6 | #include "../../include/ast_nodes.h" |
| 7 | +#include "../../include/herb.h" |
7 | 8 | #include "../../include/html_util.h" |
8 | 9 | #include "../../include/parser_helpers.h" |
9 | 10 | #include "../../include/position.h" |
@@ -687,23 +688,26 @@ static AST_NODE_T* transform_erb_block_to_tag_helper( |
687 | 688 | AST_NODE_T* close_tag = (AST_NODE_T*) block_node->end_node; |
688 | 689 |
|
689 | 690 | if (tag_name && parser_is_foreign_content_tag(hb_string_from_c_string(tag_name)) && context->source |
690 | | - && block_node->body && hb_array_size(block_node->body) > 0) { |
| 691 | + && block_node->body && hb_array_size(block_node->body) > 0 && block_node->end_node |
| 692 | + && block_node->end_node->tag_opening) { |
691 | 693 | size_t start_offset = block_node->tag_closing->range.to; |
692 | 694 | size_t end_offset = block_node->end_node->tag_opening->range.from; |
693 | 695 |
|
694 | 696 | if (end_offset > start_offset) { |
695 | 697 | position_T body_start = block_node->tag_closing->location.end; |
696 | | - position_T body_end = block_node->end_node->tag_opening->location.start; |
697 | 698 |
|
698 | 699 | size_t content_length = end_offset - start_offset; |
699 | 700 | char* raw_copy = hb_allocator_strndup(allocator, context->source + start_offset, content_length); |
700 | | - hb_string_T raw_content = { .data = raw_copy, .length = (uint32_t) content_length }; |
701 | 701 |
|
702 | | - AST_LITERAL_NODE_T* literal_node = |
703 | | - ast_literal_node_init(raw_content, body_start, body_end, hb_array_init(0, allocator), allocator); |
| 702 | + parser_options_T body_options = HERB_DEFAULT_PARSER_OPTIONS; |
| 703 | + body_options.html = false; |
| 704 | + body_options.analyze = false; |
| 705 | + body_options.strict = false; |
| 706 | + body_options.start_line = body_start.line; |
| 707 | + body_options.start_column = body_start.column; |
704 | 708 |
|
705 | | - body = hb_array_init(1, allocator); |
706 | | - hb_array_append(body, literal_node); |
| 709 | + AST_DOCUMENT_NODE_T* body_document = herb_parse(raw_copy, &body_options, allocator); |
| 710 | + body = body_document->children; |
707 | 711 | } |
708 | 712 | } |
709 | 713 |
|
|
0 commit comments