-
Notifications
You must be signed in to change notification settings - Fork 415
Support for escaping curly braces in embedded expression #3962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
639e4f9
3bce799
31d8469
0c44d92
4fdf463
ef14f09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #nullable enable | ||
|
|
||
| using Microsoft.CodeAnalysis.Text; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive.Http.Parsing; | ||
| internal class HttpEscapedCharacterSequenceNode : HttpSyntaxNode | ||
| { | ||
| public HttpEscapedCharacterSequenceNode(SourceText sourceText, HttpSyntaxTree syntaxTree) : base(sourceText, syntaxTree) | ||
| { | ||
| } | ||
|
|
||
| public string NonEscapedText => Text.TrimStart('\\'); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,6 +299,35 @@ public void single_quotes_in_variable_values_are_supported() | |
|
|
||
| } | ||
|
|
||
| [Fact] | ||
| public void double_braces_escaping_single_braces_are_supported() | ||
bleaphar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| var result = Parse( | ||
| """ | ||
|
|
||
| @text=\{{text\}} | ||
bleaphar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| ); | ||
|
|
||
| var variables = result.SyntaxTree.RootNode.TryGetDeclaredVariables().declaredVariables; | ||
| variables.Should().Contain(n => n.Key == "text").Which.Value.Should().BeOfType<DeclaredVariable>().Which.Value.Should().Be("{{text}}"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void triple_escaped_curly_braces_in_variable_values_are_supported() | ||
bleaphar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| var result = Parse( | ||
| """ | ||
|
|
||
| @text=\{{{text\}}} | ||
|
||
| """ | ||
| ); | ||
|
|
||
| var variables = result.SyntaxTree.RootNode.TryGetDeclaredVariables().declaredVariables; | ||
| variables.Should().Contain(n => n.Key == "text").Which.Value.Should().BeOfType<DeclaredVariable>().Which.Value.Should().Be("{{{text}}}"); | ||
|
|
||
| } | ||
|
|
||
| [Fact] | ||
| public void double_quotes_in_variable_values_are_supported() | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.