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

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