private LessonFile ParseFile(StringWithIndex text) { text = text.Trim(); var file = new LessonFile(text); var parts = text.SplitAfterFirstLine(); // Parse the title var titlePart = parts[0]; file.Children.Add(new LessonFileMethodReference(titlePart)); var codePart = parts[1]; file.Children.Add(new LessonCode(codePart)); return(file); }
private LessonTest ParseTest(StringWithIndex text) { text = text.Trim(); var test = new LessonTest(text); var parts = text.SplitAfterFirstLine(); // Parse the title var titlePart = parts[0]; test.Children.Add(new LessonBlankTitlePlaceholder(titlePart, "## TEST", "\r\n")); var codePart = parts[1]; test.Children.Add(new LessonCode(codePart)); return(test); }
private LessonCodeExplanation ParseCodeExplanation(StringWithIndex text) { text = text.Trim(); var codeExp = new LessonCodeExplanation(text); var parts = text.SplitAfterFirstLine(); // Parse the title var titlePart = parts[0]; codeExp.Children.Add(new LessonCodeExplanationQuote(titlePart)); // Parse the phrases var phraseTexts = parts[1].SplitWithoutModification("-"); var phrases = phraseTexts.Select(t => new LessonPhrase(t.Trim())); codeExp.AddChildren(phrases); return(codeExp); }
private LessonExplanation ParseExplanation(StringWithIndex text) { text = text.Trim(); var explanation = new LessonExplanation(text); var parts = text.SplitAfterFirstLine(); // Parse the title var titlePart = parts[0]; explanation.Children.Add(new LessonBlankTitlePlaceholder(titlePart, "## EXPLANATION", "\r\n")); // Parse explanation // Divide the parts var codeExplanationTexts = parts[1].SplitWithoutModification("\n*"); var codeExplanations = codeExplanationTexts.Where(t => !StringHelper.IsNullOrWhiteSpace(t.Text)).Select(t => ParseCodeExplanation(t)); explanation.AddChildren(codeExplanations); return(explanation); }
private LessonSummary ParseSummary(StringWithIndex text) { text = text.Trim(); var summary = new LessonSummary(text); var parts = text.SplitAfterFirstLine(); // Parse the title var titlePart = parts[0]; summary.Children.Add(new LessonBlankTitlePlaceholder(titlePart, "## SUMMARY", "\r\n")); var paragraphs = GetParagraphs(parts[1]); // Remove blank paragraphs paragraphs = paragraphs.Where(p => p.Phrases.Count > 0 || p.Code != null); summary.AddChildren(paragraphs); return(summary); }
private LessonGoal ParseGoal(StringWithIndex text) { text = text.Trim(); var goal = new LessonGoal(text); var parts = text.SplitAfterFirstLine(); // Parse the title var titlePart = parts[0]; goal.Children.Add(new LessonBlankTitlePlaceholder(titlePart, "## GOAL", "\r\n")); var paragraphs = GetParagraphs(parts[1]); // Remove blank paragraphs paragraphs = paragraphs.Where(p => p.Phrases.Count > 0 || p.Code != null); goal.AddChildren(paragraphs); return(goal); }