Example #1
0
        public ElementContent ContentAfter(ElementContent innerContent)
        {
            int last = Position + Length;
            int innerLast = innerContent.Position + innerContent.Length;

            return new ElementContent(Text, innerLast, last - innerLast);
        }
Example #2
0
        public override LinkedList<IWikiElement> Parse(ParsingContext parsingContext, ElementContent containerContent)
        {
            var elements = new LinkedList<IWikiElement>();

            foreach (Match match in _linkExpression.Matches(containerContent.ToString()))
            {
                var elementContent = new ElementContent(containerContent, match);
                var innerContent = new ElementContent(containerContent, match.Groups["content"]);

                string originalAddress, normalizedAddress;

                if (match.Groups["url"].Success)
                {
                    originalAddress = match.Groups["url"].Value;
                    normalizedAddress = FormatUrl(originalAddress);
                }
                else if (match.Groups["email"].Success)
                {
                    originalAddress = match.Groups["email"].Value;
                    normalizedAddress = FormatEmail(originalAddress);
                }
                else
                    continue;

                string text = match.Groups["text"].Success ? match.Groups["text"].Value : originalAddress;
                bool noFollow = match.Groups["nofollow"].Success;

                var element = new LinkElement(parsingContext, elementContent, innerContent, normalizedAddress, text, noFollow);

                elements.AddLast(element);
            }

            return elements;
        }
Example #3
0
        public ElementContent(ElementContent content, int relativePosition, int length)
        {
            if (relativePosition + length > content.Length)
                throw new ArgumentOutOfRangeException("length", length, "Invalid content length.");

            _text = content.Text;
            _position = content.Position + relativePosition;
            _length = length;
        }
        protected ContainerElementBase(ParsingContext parsingContext, ElementContent elementContent, ElementContent innerContent)
            : base(parsingContext, elementContent)
        {
            InnerElements = new LinkedList<IWikiElement>();
            InnerContentChunks = new LinkedList<ElementContent>();

            if (innerContent.Length > 0)
                InnerContentChunks.AddFirst(innerContent);
        }
Example #5
0
        public override LinkedList<IWikiElement> Parse(ParsingContext parsingContext, ElementContent containerContent)
        {
            if (!parsingContext.SkipLinesEnabled)
                return new LinkedList<IWikiElement>();
            
            var elements = new LinkedList<IWikiElement>();

            foreach (Match match in _skipExpression.Matches(containerContent.ToString()))
            {
                var elementContent = new ElementContent(containerContent, match);

                elements.AddLast(new SkipElement(parsingContext, elementContent));
            }

            return elements;
        }
Example #6
0
        public override LinkedList<IWikiElement> Parse(ParsingContext parsingContext, ElementContent containerContent)
        {
            var elements = new LinkedList<IWikiElement>();

            foreach (Match match in _listItemExpression.Matches(containerContent.ToString()))
            {
                var elementContent = new ElementContent(containerContent, match);
                var innerContent = new ElementContent(containerContent, match.Groups["content"]);

                var listItem = new ListItemElement(parsingContext, elementContent, innerContent);

                elements.AddLast(listItem);
            }

            return elements;
        }
Example #7
0
        public override LinkedList<IWikiElement> Parse(ParsingContext parsingContext, ElementContent containerContent)
        {
            var elements = new LinkedList<IWikiElement>();

            foreach (Match match in _formattingExpression.Matches(containerContent.ToString()))
            {
                var elementContent = new ElementContent(containerContent, match);
                var innerContent = new ElementContent(containerContent, match.Groups["content"]);

                var formatting = GetFormatting(match.Groups["symbol"].Value);

                var element = new FormattingElement(parsingContext, elementContent, innerContent, formatting);

                elements.AddLast(element);
            }

            return elements;
        }
Example #8
0
 public ElementContent ContentBefore(ElementContent innerContent)
 {
     return new ElementContent(Text, Position, innerContent.Position - Position);
 }
Example #9
0
 public ElementContent(ElementContent content, Capture capture)
     : this(content, capture.Index, capture.Length)
 {
 }
 public FormattedTextElement(ParsingContext parsingContext, ElementContent elementContent)
     : base(parsingContext, elementContent, elementContent)
 {
 }
Example #11
0
 public abstract LinkedList<IWikiElement> Parse(ParsingContext parsingContext, ElementContent containerContent);
 public ContentElementBase(ParsingContext parsingContext, ElementContent elementContent, IWikiElement innerElement)
     : base(parsingContext, elementContent)
 {
     InnerElement = innerElement;
 }
Example #13
0
 protected WikiElementBase(ParsingContext parsingContext, ElementContent elementContent)
 {
     ParsingContext = parsingContext;
     Content = elementContent;
 }
Example #14
0
 public FormattingElement(ParsingContext parsingContext, ElementContent elementContent, ElementContent innerContent, Formatting formatting)
     : base(parsingContext, elementContent, new FormattedTextElement(parsingContext, innerContent))
 {
     _formatting = formatting;
 }
Example #15
0
 public ParagraphElement(ParsingContext parsingContext, ElementContent elementContent, ElementContent innerContent)
     : base(parsingContext, elementContent, new FormattedTextElement(parsingContext, innerContent))
 {
 }
Example #16
0
 public ListElement(ParsingContext parsingContext, ElementContent elementContent, ListType listType)
     : base(parsingContext, elementContent, elementContent)
 {
     _listType = listType;
 }
Example #17
0
 public ListItemElement(ParsingContext parsingContext, ElementContent elementContent, ElementContent innerContent)
     : base(parsingContext, elementContent, new FormattedTextElement(parsingContext, innerContent))
 {
 }
Example #18
0
 public HeaderElement(ParsingContext parsingContext, ElementContent elementContent, ElementContent innerContent, int level)
     : base(parsingContext, elementContent, new FormattedTextElement(parsingContext, innerContent))
 {
     _level = level;
 }
Example #19
0
 public SkipElement(ParsingContext parsingContext, ElementContent elementContent)
     : base(parsingContext, elementContent)
 {
 }
Example #20
0
 public TextElement(ParsingContext parsingContext, ElementContent elementContent, bool disableTypography = false)
     : base(parsingContext, elementContent)
 {
     _disableTypography = disableTypography;
 }