Exemplo n.º 1
0
        private Tag ParseClosingTag(ClosingTag closingTag, Tag currentTag, Stack <Tag> tagStack)
        {
            if (String.Equals(currentTag.Name, closingTag.Name, StringComparison.OrdinalIgnoreCase))
            {
                tagStack.Pop();
            }
            else if (currentTag.RequiresClosingTag == false)
            {
                tagStack.Pop();
                currentTag = tagStack.Peek();

                if (String.Equals(currentTag.Name, closingTag.Name, StringComparison.OrdinalIgnoreCase))
                {
                    tagStack.Pop();
                }
                else
                {
                    currentTag.Add(CreateContent(closingTag.ToString()));
                }
            }
            else
            {
                currentTag.Add(CreateContent(closingTag.ToString()));
            }
            return(currentTag);
        }
Exemplo n.º 2
0
        public void RelatedIndex_Test()
        {
            var instance = new OpeningTag();
            var related  = new ClosingTag
            {
                Position = 10
            };

            instance.Related = related;

            Assert.AreEqual(10, instance.RelatedPosition);
        }
Exemplo n.º 3
0
        public void Render_Test()
        {
            var related  = new OpeningTag();
            var instance = new ClosingTag
            {
                Related    = related,
                TextBefore = "some stuff"
            };

            var renderOutput = instance.Render();

            Assert.AreEqual("some stuff</div>", renderOutput);
        }
Exemplo n.º 4
0
            public void Validate(MarkdownTagInlineToken token)
            {
                var  m            = OpeningTag.Match(token.SourceInfo.Markdown);
                bool isOpeningTag = true;

                if (m.Length == 0)
                {
                    m = ClosingTag.Match(token.SourceInfo.Markdown);
                    if (m.Length == 0)
                    {
                        return;
                    }
                    isOpeningTag = false;
                }

                ValidateCore(token, m, isOpeningTag);
            }
            public IMarkdownToken Validate(MarkdownEngine engine, MarkdownTagInlineToken token)
            {
                var  m            = OpeningTag.Match(token.Content);
                bool isOpeningTag = true;

                if (m.Length == 0)
                {
                    m = ClosingTag.Match(token.Content);
                    if (m.Length == 0)
                    {
                        return(null);
                    }
                    isOpeningTag = false;
                }

                return(ValidateCore(token, m, isOpeningTag));
            }
Exemplo n.º 6
0
        public void Render_Test()
        {
            var instance = new OpeningTag()
            {
                TextAfter = "some stuff"
            };
            var related = new ClosingTag
            {
                Position = 10
            };

            instance.Related = related;

            var renderOuput = instance.Render();

            Assert.AreEqual("<div>some stuff", renderOuput);
        }
Exemplo n.º 7
0
        public void ClosingTag_Test()
        {
            var related = new OpeningTag
            {
                Position = 10,
                Name     = "span",
                //Z = 100
            };
            var instance = new ClosingTag
            {
                Position = 20,
                Related  = related,
            };

            Assert.AreSame(related, instance.Related);
            Assert.AreEqual(related.Name, instance.Name);
            Assert.AreEqual(20, instance.Position);
            Assert.AreEqual(related.Position, instance.RelatedPosition);
            //Assert.AreEqual(related.Z, instance.Z);
        }
Exemplo n.º 8
0
        public override void BuildTreeString(StringBuilder builder, int indentLevel)
        {
            builder.Append(' ', indentLevel * 2);
            builder.AppendFormat("[XElement Name='{0}' Location='{1}' Children=", Name.FullName, Span);
            builder.AppendLine();

            foreach (XNode child in Nodes)
            {
                child.BuildTreeString(builder, indentLevel + 1);
            }

            builder.Append(' ', indentLevel * 2);
            builder.Append("Attributes=");
            builder.AppendLine();

            foreach (XAttribute att in Attributes)
            {
                att.BuildTreeString(builder, indentLevel + 1);
            }

            if (ClosingTag is XClosingTag)
            {
                builder.AppendLine("ClosingTag=");
                ClosingTag.BuildTreeString(builder, indentLevel + 1);
            }
            else if (ClosingTag == null)
            {
                builder.AppendLine("ClosingTag=(null)");
            }
            else
            {
                builder.AppendLine("ClosingTag=(Self)");
            }

            builder.Append(' ', indentLevel * 2);
            builder.AppendLine("]");
        }
Exemplo n.º 9
0
 protected bool Equals(ClosingTag other)
 {
     return
         (other != null &&
          string.Equals(Name, other.Name));
 }