Skip to content

Commit

Permalink
escape text
Browse files Browse the repository at this point in the history
  • Loading branch information
crcn committed Jan 14, 2024
1 parent c82a00c commit 3de411e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- Start consolidating components + cleaning them up
- ability to detach instances

- detach lightning icon

- ability to parse comments
2 changes: 1 addition & 1 deletion libs/core/src/proto/ast_mutate/set_text_node_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl MutableVisitor<()> for EditContext<SetTextNodeValue> {
return VisitorResult::Continue;
}

expr.value = self.mutation.value.to_string();
expr.value = self.mutation.value.to_string().replace("\"", "\\\"");

self.add_change(
mutation_result::Inner::ExpressionUpdated(ExpressionUpdated {
Expand Down
21 changes: 21 additions & 0 deletions libs/core/src/proto/ast_mutate/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,27 @@ case! {
)]
}

case! {
can_use_quotes_with_text_node_value,
[
(
"/entry.pc", r#"
text "a"
"#
)
],

mutation::Inner::SetTextNodeValue(SetTextNodeValue {
text_node_id: "80f4925f-1".to_string(),
value: "b\"c\"".to_string()
}).get_outer(),
[(
"/entry.pc", r#"
text "b\"c\""
"#
)]
}

case! {
can_change_the_id_of_an_element,
[
Expand Down
11 changes: 11 additions & 0 deletions libs/parser/src/pc/tests/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ add_case! {
"#
}

add_case! {
can_parse_a_string_with_quotes,
r#"
component A {
render div {
text "abc \"def\""
}
}
"#
}

add_case! {
can_parse_attributes,
r#"
Expand Down

0 comments on commit 3de411e

Please sign in to comment.