public class Html extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Html.ImageGetter
Retrieves images for HTML <img> tags.
|
static interface |
Html.TagHandler
Is notified when HTML tags are encountered that the parser does
not know how to interpret.
|
Modifier and Type | Field and Description |
---|---|
static int |
FROM_HTML_MODE_COMPACT
Flags for
fromHtml(String, int, ImageGetter, TagHandler) : Separate block-level
elements with line breaks (single newline character) in between. |
static int |
FROM_HTML_MODE_LEGACY
Flags for
fromHtml(String, int, ImageGetter, TagHandler) : Separate block-level
elements with blank lines (two newline characters) in between. |
static int |
FROM_HTML_OPTION_USE_CSS_COLORS
Flag indicating that CSS color values should be used instead of those defined in
Color . |
static int |
FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE
Flag indicating that texts inside <blockquote> elements will be separated from other
texts with one newline character by default.
|
static int |
FROM_HTML_SEPARATOR_LINE_BREAK_DIV
Flag indicating that texts inside <div> elements will be separated from other texts
with one newline character by default.
|
static int |
FROM_HTML_SEPARATOR_LINE_BREAK_HEADING
Flag indicating that texts inside <h1>~<h6> elements will be separated from
other texts with one newline character by default.
|
static int |
FROM_HTML_SEPARATOR_LINE_BREAK_LIST
Flag indicating that texts inside <ul> elements will be separated from other texts
with one newline character by default.
|
static int |
FROM_HTML_SEPARATOR_LINE_BREAK_LIST_ITEM
Flag indicating that texts inside <li> elements will be separated from other texts
with one newline character by default.
|
static int |
FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH
Flag indicating that texts inside <p> elements will be separated from other texts with
one newline character by default.
|
static int |
TO_HTML_PARAGRAPH_LINES_CONSECUTIVE
Option for
toHtml(Spanned, int) : Wrap consecutive lines of text delimited by '\n'
inside <p> elements. |
static int |
TO_HTML_PARAGRAPH_LINES_INDIVIDUAL
Option for
toHtml(Spanned, int) : Wrap each line of text delimited by '\n' inside a
<p> or a <li> element. |
Modifier and Type | Method and Description |
---|---|
static String |
escapeHtml(CharSequence text)
Returns an HTML escaped representation of the given plain text.
|
static Spanned |
fromHtml(String source)
Deprecated.
use
fromHtml(String, int) instead. |
static Spanned |
fromHtml(String source,
Html.ImageGetter imageGetter,
Html.TagHandler tagHandler)
Deprecated.
use
fromHtml(String, int, ImageGetter, TagHandler) instead. |
static Spanned |
fromHtml(String source,
int flags)
Returns displayable styled text from the provided HTML string.
|
static Spanned |
fromHtml(String source,
int flags,
Html.ImageGetter imageGetter,
Html.TagHandler tagHandler)
Returns displayable styled text from the provided HTML string.
|
static String |
toHtml(Spanned text)
Deprecated.
use
toHtml(Spanned, int) instead. |
static String |
toHtml(Spanned text,
int option)
Returns an HTML representation of the provided Spanned text.
|
public static final int TO_HTML_PARAGRAPH_LINES_CONSECUTIVE
toHtml(Spanned, int)
: Wrap consecutive lines of text delimited by '\n'
inside <p> elements. BulletSpan
s are ignored.public static final int TO_HTML_PARAGRAPH_LINES_INDIVIDUAL
toHtml(Spanned, int)
: Wrap each line of text delimited by '\n' inside a
<p> or a <li> element. This allows ParagraphStyle
s attached to be
encoded as CSS styles within the corresponding <p> or <li> element.public static final int FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_HEADING
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST_ITEM
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_DIV
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE
public static final int FROM_HTML_OPTION_USE_CSS_COLORS
Color
.public static final int FROM_HTML_MODE_LEGACY
fromHtml(String, int, ImageGetter, TagHandler)
: Separate block-level
elements with blank lines (two newline characters) in between. This is the legacy behavior
prior to N.public static final int FROM_HTML_MODE_COMPACT
fromHtml(String, int, ImageGetter, TagHandler)
: Separate block-level
elements with line breaks (single newline character) in between. This inverts the
Spanned
to HTML string conversion done with the option
TO_HTML_PARAGRAPH_LINES_INDIVIDUAL
.@Deprecated public static Spanned fromHtml(String source)
fromHtml(String, int)
instead.FROM_HTML_MODE_LEGACY
.public static Spanned fromHtml(String source, int flags)
This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
@Deprecated public static Spanned fromHtml(String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)
fromHtml(String, int, ImageGetter, TagHandler)
instead.FROM_HTML_MODE_LEGACY
.public static Spanned fromHtml(String source, int flags, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)
This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
@Deprecated public static String toHtml(Spanned text)
toHtml(Spanned, int)
instead.public static String toHtml(Spanned text, int option)
text
- input text to convertoption
- one of TO_HTML_PARAGRAPH_LINES_CONSECUTIVE
or
TO_HTML_PARAGRAPH_LINES_INDIVIDUAL
public static String escapeHtml(CharSequence text)