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); }
public void RelatedIndex_Test() { var instance = new OpeningTag(); var related = new ClosingTag { Position = 10 }; instance.Related = related; Assert.AreEqual(10, instance.RelatedPosition); }
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); }
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)); }
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); }
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); }
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); }