예제 #1
0
        public bool HandleLine(MarkdownNode context, string line)
        {
            line = line.Trim();
            bool isBullet;
            int  skip;

            if (line.StartsWith("-"))
            {
                isBullet = true;
                skip     = 1;
            }
            else if (line.StartsWith("#."))
            {
                isBullet = false;
                skip     = 2;
            }
            else
            {
                return(false);
            }

            var bulletNode = new MarkdownNode()
            {
                Type = isBullet ? MarkdownType.Bulleted : MarkdownType.Numbered,
            };

            context.AddChild(bulletNode);

            AppendParsedTextTo(bulletNode, line.Substring(skip).Trim());

            return(true);
        }
예제 #2
0
        public bool HandleLine(MarkdownNode context, string line)
        {
            line = line.Trim();
            var headingTag = GetHeadingTag(line);

            if (headingTag == null)
            {
                return(false);
            }

            MarkdownType type;

            switch (headingTag)
            {
            case "#": type = MarkdownType.Heading1; break;

            case "##": type = MarkdownType.Heading2; break;

            case "###": type = MarkdownType.Heading3; break;

            default: return(false);
            }

            string headingText = line.Substring(headingTag.Length).Trim();
            var    node        = new MarkdownNode()
            {
                Type = type,
                Text = headingText
            };

            context.AddChild(node);
            return(true);
        }
예제 #3
0
        public bool HandleLine(MarkdownNode context, string line)
        {
            line = line.Trim();
            var para = new MarkdownNode()
            {
                Type = MarkdownType.Paragraph
            };

            context.AddChild(para);

            AppendParsedTextTo(para, line);

            return(true);
        }