static void MakeNodesRecoursive(TextProccesor proc, TextNode root, INodeMarkUpSpecification specs, NodeHeader openedHeader = null) { TextNodeType currType = openedHeader == null ? TextNodeType.NONE : openedHeader.type; TextNode currNode; while (proc.IsNext()) { currNode = null; var text = proc.NextTill(specs.OpenMark); // look for "{|" if (!string.IsNullOrEmpty(text)) { currNode = new TextNode(text); } if (!proc.IsNext()) { if (currNode != null) { root.AddChild(currNode); } break; } proc.Move(specs.OpenMark.Length); // skips "{|" NodeHeader newNodeHeader = null; try { newNodeHeader = new NodeHeader(proc.NextTill(specs.CloseMark), specs); //look for "}" } catch (TextParseException e) { throw new TextParseException(e.Message + " at: " + proc.AllTextTillCurent()); } proc.Move(specs.CloseMark.Length); // skips "}" if (specs.DestroyNewLineAfterMarkUp) { proc.TryEat(specs.NewLineSymbol); } if (newNodeHeader.Enclosing) { if (newNodeHeader.type == currType) { if (currNode != null) { root.AddChild(currNode); } break; //node done } else { throw new TextParseException("Unexpected enclosing keyword: " + newNodeHeader.Name); } } var subRootNode = new TextNode(newNodeHeader.type); subRootNode.paramsString = newNodeHeader.Params; if (currNode != null) { root.AddChild(currNode); } root.AddChild(subRootNode); MakeNodesRecoursive(proc, subRootNode, specs, newNodeHeader); } }
/// <summary> /// Creates a TextNode that can be a parent /// </summary> public TextNode(TextNodeType type) { if (type == TextNodeType.plain) { throw new ArgumentException("Plain textNode should have content. Use another constructor"); } this.type = type; }
public NodeHeader(string nodeHeaderFullString, INodeMarkUpSpecification specs) { var strings = nodeHeaderFullString.Split(splitters, StringSplitOptions.RemoveEmptyEntries); if (strings[0].StartsWith(specs.NodeClose_OpenMarkPostfix)) { Enclosing = true; strings[0] = strings[0].Substring(1); } Name = strings[0]; type = StrToNodeType(strings[0], specs); Params = nodeHeaderFullString; }
public TextNode(TextNodeType Type, string Text) { this.Type = Type; this.Text = Text; }
public TextNode(TextNodeType Type, string Text) { this.Type = Type; this.Text = Text; }
/// <summary> /// Creates a Plain TextNode /// </summary> public TextNode(string content) { this.content = content; type = TextNodeType.plain; }
public TextNode(TextNodeType type, string text){ this.Type = type; this.Text = text; }
/// <summary> /// Creates a new instance of <see cref="TextNode"/> /// </summary> /// <param name="type">The text node type</param> /// <param name="text">The text node text</param> public TextNode(TextNodeType type, string text) { Type = type; Text = text; }
public TextNode(TextNodeType type, string text) { this.Type = type; this.Text = text; }