public void Should_handle_nested_blocks() { var bc = _converter.ConvertHtml("<div>This should <div>NEW</div> be parsed</div>"); Assert.Equal(3, bc.Count); Assert.Contains("This should", bc[0].Children[0].Text); Assert.Contains("NEW", bc[1].Children[0].Text); Assert.Contains("be parsed", bc[2].Children[0].Text); }
public void Should_handle_snippet_1() { var bc = _converter.ConvertHtml( @"<p><a href='link1'>a<strong>b</strong>c</a> <em>d<a href='link2'>e</a></em>f</p> "); //block Assert.Single(bc); Assert.Equal(6, bc[0].Children.Count); Assert.NotEmpty(bc[0].Key); Assert.Null(bc[0].Level); Assert.Null(bc[0].ListItem); Assert.Equal("normal", bc[0].Style); Assert.Equal("block", bc[0].Type); //order of spans Assert.Equal("a", bc[0].Children[0].Text); Assert.Equal("b", bc[0].Children[1].Text); Assert.Equal("c", bc[0].Children[2].Text); Assert.Equal("d", bc[0].Children[3].Text); Assert.Equal("e", bc[0].Children[4].Text); Assert.Equal("f", bc[0].Children[5].Text); //marks on spans Assert.Single(bc[0].Children[0].Marks); Assert.Equal(2, bc[0].Children[1].Marks.Count()); Assert.Single(bc[0].Children[2].Marks); Assert.Single(bc[0].Children[3].Marks); Assert.Equal(2, bc[0].Children[4].Marks.Count()); Assert.Empty(bc[0].Children[5].Marks); //markdefs on block var keys = bc[0].MarkDefs.Select(p => p.Key).ToList(); var m1 = keys.Intersect(bc[0].Children[1].Marks).Count(); var m2 = keys.Intersect(bc[0].Children[4].Marks).Count(); Assert.Equal(1, m1); Assert.Equal(1, m2); }
public void Should_create_children() { var bc = _converter.ConvertHtml("<br/>"); Assert.Equal("\n", bc[0].Children[0].Text); }
public void Should_set_correct_mark_on_block() { var bc = _converter.ConvertHtml("<p>This is a <a href=\"http\">link</a></p>"); Assert.Equal(bc[0].MarkDefs[0].Key, bc[0].Children[1].Marks[0]); }
public void Should_set_mark() { var bc = _converter.ConvertHtml("<div><b>this is bold</b></div>"); Assert.Contains("strong", bc[0].Children[0].Marks[0]); }
public void Should_handle_correct_nesting() { var bc = _converter.ConvertHtml("<ul><li><ul><li>double indent</li></ul></li></ul>"); Assert.Equal(2, bc[0].Level); }