fixed square brackets bug

This commit is contained in:
2024-03-29 15:08:15 -06:00
parent af60bd1e46
commit 8df3a34dde
3 changed files with 31 additions and 3 deletions

View File

@@ -94,4 +94,32 @@ Which events are triggered when the user clicks on an input field?
question.Answers.First().Text.Should().Be("`int[] theThing()`"); question.Answers.First().Text.Should().Be("`int[] theThing()`");
question.Answers.Count().Should().Be(2); question.Answers.Count().Should().Be(2);
} }
[Test]
public void CanUseBracesInAnswerFormultipleAnswer_MultiLine()
{
var rawMarkdownQuestion = @"
Which events are triggered when the user clicks on an input field?
[*]
```
int[] myNumbers = new int[] { };
DoSomething(ref myNumbers);
static void DoSomething(ref int[] numbers)
{
// do something
}
```
";
var question = LocalQuizQuestion.ParseMarkdown(rawMarkdownQuestion, 0);
question.Answers.First().Text.Should().Be(@"```
int[] myNumbers = new int[] { };
DoSomething(ref myNumbers);
static void DoSomething(ref int[] numbers)
{
// do something
}
```");
question.Answers.Count().Should().Be(1);
}
} }

View File

@@ -2,7 +2,7 @@ using System.Diagnostics;
public interface ITraceableMessage public interface ITraceableMessage
{ {
public ActivitySpanId? ParentSpan {get;} public ActivitySpanId? ParentSpan { get; }
public ActivityTraceId? ParentTrace {get;} public ActivityTraceId? ParentTrace { get; }
} }

View File

@@ -153,7 +153,7 @@ public record LocalQuizQuestion
var answerLinesRaw = linesWithoutPoints[indexOfAnswerStart..]; var answerLinesRaw = linesWithoutPoints[indexOfAnswerStart..];
var answerStartPattern = @"^(\*?[a-z]?\))|\[\s*\]|\[\*\]|\^"; var answerStartPattern = @"^(\*?[a-z]?\))|(?<!\S)\[\s*\]|\[\*\]|\^";
var answerLines = answerLinesRaw.Aggregate(new List<string>(), (acc, line) => var answerLines = answerLinesRaw.Aggregate(new List<string>(), (acc, line) =>
{ {
var isNewAnswer = Regex.IsMatch(line, answerStartPattern); var isNewAnswer = Regex.IsMatch(line, answerStartPattern);