Represents a paragraph of text Paragraph is a block element
Inheritance: XBlock
Beispiel #1
0
        public static XTextElement Parse(string str)
        {
            str = str.Replace("\r\n", "\n");

            if (str.IndexOf("\n\n", StringComparison.Ordinal) != -1 || str.EndsWith("\n"))
            {
                var isLastAParagraph = str.EndsWith("\n");
                var paragraphs       = str.TrimEnd('\n').Split(new[] { "\n\n" }, StringSplitOptions.None);
                var parsed           = paragraphs.Select(ParseBlock).ToArray();
                for (var i = 0; i < parsed.Length; i++)
                {
                    var isLast = i == parsed.Length - 1;

                    if (isLast && !isLastAParagraph)
                    {
                        continue;
                    }
                    if (parsed[i] is XInline)
                    {
                        parsed[i] = new XParagraph((XInline)parsed[i]);
                    }
                }

                if (paragraphs.Length == 1)
                {
                    return(parsed.Single());
                }
                return(new XSection(parsed));
            }

            return(ParseBlock(str));
        }
Beispiel #2
0
        public static XTextElement Parse(string str)
        {
            str = str.Replace("\r\n", "\n");

            if (str.IndexOf("\n\n", StringComparison.Ordinal) != -1 || str.EndsWith("\n"))
            {
                var isLastAParagraph = str.EndsWith("\n");
                var paragraphs = str.TrimEnd('\n').Split(new[] { "\n\n" }, StringSplitOptions.None);
                var parsed = paragraphs.Select(ParseBlock).ToArray();
                for (var i = 0; i < parsed.Length; i++)
                {
                    var isLast = i == parsed.Length - 1;

                    if (isLast && !isLastAParagraph) continue;
                    if (parsed[i] is XInline) parsed[i] = new XParagraph((XInline) parsed[i]);
                }

                if (paragraphs.Length == 1)
                    return parsed.Single();
                return new XSection(parsed);
            }

            return ParseBlock(str);
        }
Beispiel #3
0
 protected bool Equals(XParagraph other)
 {
     return(base.Equals(other) && ListEquals(children, other.children));
 }
Beispiel #4
0
 protected bool Equals(XParagraph other)
 {
     return base.Equals(other) && ListEquals(children, other.children);
 }