コード例 #1
0
        /// <returns>return <see cref="ListNode" /> instances</returns>
        protected override Node CreateNode(Match regExpMatch)
        {
            var node = (ListNode)base.CreateNode(regExpMatch);

            node.Content = regExpMatch.Groups[2].Value;
            node.Level   = regExpMatch.Groups[1].Value.Length / 2;

            // content of the node can contain some inline nodes, e.g. bold text etc.
            var blockContentParser = new BlockContentParser();

            node.Nodes = blockContentParser.GetNodes(node.Content).ToList();
            return(node);
        }
コード例 #2
0
        internal Node[] Parse(string wikiText)
        {
            var blockNodesParser = new BlockNodesParser();
            var blockNodes       = blockNodesParser.GetNodes(wikiText);

            // there aren't any blocks, consider whole text as one block and return it's nodes
            if (!blockNodes.Any() && !string.IsNullOrEmpty(wikiText))
            {
                var blockContentParser = new BlockContentParser();
                return(blockContentParser.GetNodes(wikiText));
            }

            foreach (var paragraphNode in blockNodes.Where(n => n.Type == NodeType.ParagraphNode))
            {
                var blockContentParser = new BlockContentParser();
                var nodes = blockContentParser.GetNodes(paragraphNode.Content);
                paragraphNode.Nodes.AddRange(nodes);
            }

            return(blockNodes);
        }