示例#1
0
        private Tag ParseOpeningTag(OpeningTag openingTag, Tag currentTag, Stack <Tag> tagStack)
        {
            var tagReference = FindTagReference(openingTag.Name);

            if (tagReference == null)
            {
                currentTag.Add(CreateContent(openingTag.ToString()));
            }
            else
            {
                if (currentTag.RequiresClosingTag == false)
                {
                    tagStack.Pop();
                    currentTag = tagStack.Peek();
                }

                var newTag = new Tag(tagReference, openingTag.Value);
                currentTag.Add(newTag);

                if (openingTag.IsSelfClosing == false)
                {
                    tagStack.Push(newTag);
                }
            }
            return(currentTag);
        }
示例#2
0
        public void RelatedIndex_Test()
        {
            var instance = new OpeningTag();
            var related  = new ClosingTag
            {
                Position = 10
            };

            instance.Related = related;

            Assert.AreEqual(10, instance.RelatedPosition);
        }
示例#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);
        }
示例#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));
            }
示例#6
0
        public void Render_AttributesTest()
        {
            var instance = new OpeningTag
            {
                Name       = "span",
                Attributes = new Dictionary <string, string>()
                {
                    { "id", "0" },
                    { "class", "basic-text" },
                    { "style", "color: red" }
                }
            };

            string renderOutput = instance.Render();

            Assert.AreEqual("<span id=\"0\" class=\"basic-text\" style=\"color: red\">", renderOutput);
        }
示例#7
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);
        }
示例#8
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);
        }