public void testSplitAnEmbolden() { Document doc = NSoup.NSoupClient.Parse("<div>Hello there</div>"); Element div = doc.Select("div").First; TextNode tn = (TextNode)div.ChildNodes[0]; TextNode tail = tn.SplitText(6); tail.Wrap("<b></b>"); Assert.AreEqual("Hello <b>there</b>", TextUtil.StripNewLines(div.Html())); // not great that we get \n<b>there there... must correct }
public void testSplitText() { Document doc = NSoup.NSoupClient.Parse("<div>Hello there</div>"); Element div = doc.Select("div").First; TextNode tn = (TextNode)div.ChildNodes[0]; TextNode tail = tn.SplitText(6); Assert.AreEqual("Hello ", tn.GetWholeText()); Assert.AreEqual("there", tail.GetWholeText()); tail.Text("there!"); Assert.AreEqual("Hello there!", div.Text()); Assert.IsTrue(tn.ParentNode == tail.ParentNode); }
public void TestSplitText() { Document doc = Dcsoup.Parse("<div>Hello there</div>"); Element div = doc.Select("div").First; TextNode tn = (TextNode)div.ChildNode(0); TextNode tail = tn.SplitText(6); Assert.AreEqual("Hello ", tn.WholeText); Assert.AreEqual("there", tail.WholeText); tail.Text = "there!"; Assert.AreEqual("Hello there!", div.Text); Assert.IsTrue(tn.Parent == tail.Parent); }