public IEnumerable<MamlCommand> NodeModelToMamlModel(DocumentNode node) { _root = node; if (_root.Children == null) { // HACK: _rootEnumerator = (new LinkedList<MarkdownNode>()).GetEnumerator(); } else { _rootEnumerator = _root.Children.GetEnumerator(); } List<MamlCommand> commands = new List<MamlCommand>(); MarkdownNode markdownNode; while ((markdownNode = GetNextNode()) != null) { if (markdownNode is HeadingNode) { var headingNode = markdownNode as HeadingNode; switch (headingNode.HeadingLevel) { case COMMAND_NAME_HEADING_LEVEL: { MamlCommand command = new MamlCommand() { Name = headingNode.Text, Extent = headingNode.SourceExtent }; if (_infoCallback != null) { Console.WriteLine("Start processing command " + command.Name); } // fill up command while (SectionDispatch(command)) { } commands.Add(command); break; } default: throw new HelpSchemaException(headingNode.SourceExtent, "Booo, I don't know what is the heading level " + headingNode.HeadingLevel); } } } return commands; }
public DocumentNode ParseString(string[] markdownStrings) { this.InitializePatternList(); _currentDocument = new DocumentNode(); foreach (string markdownString in markdownStrings) { if (string.IsNullOrWhiteSpace(markdownString)) { continue; } // Trim the leading whitespace off of the string _documentText = this.PrepareDocumentString(markdownString); this.ParseDocument(); } return _currentDocument; }