Пример #1
0
        static void Parse()
        {
            GithubMarkdown parser = new GithubMarkdown();
            //var match = parser.GetMatch("\n#hahaha\n##\nsdfsdfsdf\n132213\n12312\n>12321>33\nhaha\n\n>>yes\n>3", parser.Document);
            string testStr =
                @">sdf
>>>>sdf1

>>sdf2
>>>df22
>sdf3
";
            //Console.WriteLine(testStr);
            var match = parser.GetMatch(testStr, parser.Document);

            if (match.Success)
            {
                MarkdownElementBase res = match.Results.First();

                Console.WriteLine("result: \n{0}", res); // should print "14"
            }
            else
            {
                Console.WriteLine("error: {0}", match.Error); // shouldn't happen
            }
        }
Пример #2
0
        private static void PostMergeBlockquotes(MarkdownElementBase[] innerBlocks, MarkdownDocument root)
        {
            BlockquoteElement currentPreceBlockquote = null;

            for (int i = 0; i < innerBlocks.Length; i++)
            {
                MarkdownElementBase innerBlock = innerBlocks[i];
                if (innerBlock.Type == ElementType.Blockquote)
                {
                    BlockquoteElement currentBlockquote = innerBlock as BlockquoteElement;
                    if (currentPreceBlockquote == null || currentPreceBlockquote.QuoteLevel < currentBlockquote.QuoteLevel)
                    {
                        currentPreceBlockquote = currentBlockquote;
                        root.AddChildElement(currentPreceBlockquote);
                    }
                    else
                    {
                        currentPreceBlockquote.AddChildrenElements(currentBlockquote.Children);
                    }
                }
                else
                {
                    if (innerBlock.Type != ElementType.BlankLine)
                    {
                        root.AddChildElement(innerBlock);
                    }
                    else
                    {
                        currentPreceBlockquote = null;
                    }
                }
            }
        }