public override AstNode Process(ParserReader parser) { var reader = parser.Input; if(parser.Text.StartsWith("-#")) { // skip all children parser.ParseChildren(parser.Indent, null); return null; } var node = new CommentNode(); reader.Skip("/"); reader.SkipWhiteSpaces(); if(reader.CurrentChar == '[') { reader.Skip("["); node.Condition = reader.ReadWhile(c => c != ']'); } else if(!reader.IsEndOfStream) { var index = reader.Index; var text = reader.ReadToEndMultiLine(); node.Child = parser.ParseText(text, index); } if (reader.NextLine != null && reader.NextLine.Indent > reader.CurrentLine.Indent) { node.Child = parser.ParseChildren(parser.Indent, node.Child); } return node; }
public override void Visit(CommentNode node) { if(string.IsNullOrEmpty(node.Condition)) { WriteText("<!--"); var space = !( node.Child is ChildrenNode ); if(space) WriteText(" "); Visit(node.Child); if(space) WriteText(" "); WriteText("-->"); } else { WriteText(String.Format("<!--[{0}]>", node.Condition)); Indent++; VisitAndIdentAlways(node.Child); Indent--; WriteIndent(); WriteText("<![endif]-->"); } }
public virtual void Visit(CommentNode node) { if(node.Child != null) Visit(node.Child); }