public HamlDocument ParseHamlFile(HamlFile hamlFile) { var result = new HamlDocument(); ParseNode(result, hamlFile); return result; }
public void ParseHamlFile_UnknownRuleType_ThrowsUnknownRuleException() { var fakeLine = new HamlLineFake("") {HamlRule = HamlRuleEnum.Unknown}; var file = new HamlFile(); file.AddLine(fakeLine); Assert.Throws<HamlUnknownRuleException>(() => _parser.ParseHamlFile(file)); }
public HamlFile Read(TextReader reader) { if (reader == null) throw new ArgumentNullException("reader"); var result = new HamlFile(); while (_eof == false) { string currentLine = ReadLine(reader); //if ((!string.IsNullOrEmpty(currentLine)) || (_eof == false)) result.AddLine(new HamlLine(currentLine)); } return result; }
private void ParseNode(HamlNode node, HamlFile hamlFile) { node.IsMultiLine = true; while ((!hamlFile.EndOfFile) && (hamlFile.CurrentLine.IndentCount > node.IndentCount)) { HamlLine nodeLine = hamlFile.CurrentLine; HamlNode childNode = GetHamlNode(nodeLine); node.Add(childNode); hamlFile.MoveNext(); if (hamlFile.EndOfFile == false) { childNode.Add(new HamlNodeText(new HamlLine("\n"))); if (hamlFile.CurrentLine.IndentCount > nodeLine.IndentCount) { ParseNode(childNode, hamlFile); } } } }