Skip to content

Commit

Permalink
Fix bug of accepting content for layout tag
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Dec 25, 2024
1 parent 37ec96e commit 335fe31
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
2 changes: 2 additions & 0 deletions example/input.salam
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
رنگ پس زمینه = «قرمز»
اندازه قلم = ۴۰

محتوا = "r"

تمام
2 changes: 1 addition & 1 deletion src/generated-config/ast_layout_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// ----------- BEGIN AUTO GENERATED ----------- //
ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_INCLUDE, "INCLUDE", "include", "", "بارگیری", false)

ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_PARAGRAPH_RAW, "PARAGRAPH_RAW", "paragraph_raw", "", "محتوا", false)
// ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_PARAGRAPH_RAW, "PARAGRAPH_RAW", "paragraph_raw", "", "محتوا", false)

ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_ERROR, "ERROR", "error", "", "خطا", false)

Expand Down
2 changes: 0 additions & 2 deletions src/generated-config/ast_layout_type_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ else if (attribute->parent_node_type == AST_LAYOUT_TYPE_INCLUDE) {
return true;
}
}
else if (attribute->parent_node_type == AST_LAYOUT_TYPE_PARAGRAPH_RAW) {
}
else if (attribute->parent_node_type == AST_LAYOUT_TYPE_ERROR) {
}
else if (attribute->parent_node_type == AST_LAYOUT_TYPE_NONE) {
Expand Down
33 changes: 10 additions & 23 deletions src/validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,33 +170,20 @@ bool token_belongs_to_ast_layout_node(
ast_layout_attribute_t *attribute) {
DEBUG_ME;

if ((attribute->parent_node_type == AST_LAYOUT_TYPE_INPUT) &&
(attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_CONTENT)) {
attribute->final_key = string_strdup("value");
return true;
} else if (is_layout_node_a_single_tag(attribute->parent_node_type) &&
attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_CONTENT) {
return false;
// } else if (attribute->parent_node_type == AST_LAYOUT_TYPE_LABEL &&
// attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_FOR) {
// return true;
// } else if (attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_CONTENT) {
// return true;
// } else if (attribute->parent_node_type == AST_LAYOUT_TYPE_DIV &&
// attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_CONTENT) {
// return true;
// } else if (attribute->parent_node_type == AST_LAYOUT_TYPE_INCLUDE &&
// (attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_SRC ||
// attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_REPEAT))
// {
// attribute->ignoreMe = true;
// return true;
if (attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_CONTENT) {
return is_layout_node_a_single_tag(attribute->parent_node_type) ? false : true;
} else if (attribute->parent_node_type == AST_LAYOUT_TYPE_INCLUDE &&
(attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_SRC ||
attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_REPEAT))
{
attribute->ignoreMe = true;

return true;
} else if (attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_REPEAT) {
// TODO: add validation to only accepts positive integer
attribute->ignoreMe = true;

return true;
// } else if (attribute_key_type == AST_LAYOUT_ATTRIBUTE_TYPE_GROUP) {
// return true;
} else if (is_style_attribute(attribute_key_type)) {
attribute->isStyle = true;

Expand Down

0 comments on commit 335fe31

Please sign in to comment.