Code example for SpannableString

Methods: toHtml

0
        assertEquals(Html.toHtml(s), "<p>Hello world<br>\nor something</p>\n");
 
        s = new SpannableString("Hello world\n\nor something");
        assertEquals(Html.toHtml(s), "<p>Hello world</p>\n<p>or something</p>\n");
 
        s = new SpannableString("Hello world\n\n\nor something");
        assertEquals(Html.toHtml(s), "<p>Hello world<br></p>\n<p>or something</p>\n");
 
        assertEquals("foo\nbar", Html.fromHtml("foo<br>bar").toString());
        assertEquals("foo\nbar", Html.fromHtml("foo<br>\nbar").toString());
        assertEquals("foo\nbar", Html.fromHtml("foo<br>\n \nbar").toString());
    } 
 
    @SmallTest 
    public void testBlockquote() throws Exception { 
        SpannableString s;
 
        s = new SpannableString("Hello world");
        s.setSpan(new QuoteSpan(), 0, s.length(), Spannable.SPAN_PARAGRAPH);
        assertEquals(Html.toHtml(s), "<blockquote><p>Hello world</p>\n</blockquote>\n");