public final class

HtmlToText

extends Object
java.lang.Object
   ↳ com.google.gdata.util.common.html.HtmlToText

Class Overview

Convert provided html formatted string to text format.

Summary

Constants
int EMAIL_LINE_WIDTH_MAX Maximum length of a line in email body (in characters)
Fields
private static final Pattern htmlListPattern Regular expression to match list tags and adjacent whitespace
private static final Pattern htmlNewlinePattern Regular expression to match html line breaks or paragraph tags and adjacent whitespace
private static final Pattern htmlTagPattern Regular expression to match any remaining html tags
Public Methods
static String htmlToPlainText(String html)
Convert provided html string to plain text preserving the formatting as much as possible.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int EMAIL_LINE_WIDTH_MAX

Maximum length of a line in email body (in characters)

Constant Value: 72 (0x00000048)

Fields

private static final Pattern htmlListPattern

Regular expression to match list tags and adjacent whitespace

private static final Pattern htmlNewlinePattern

Regular expression to match html line breaks or paragraph tags and adjacent whitespace

private static final Pattern htmlTagPattern

Regular expression to match any remaining html tags

Public Methods

public static String htmlToPlainText (String html)

Convert provided html string to plain text preserving the formatting as much as possible. Ensure line wrapping to 72 chars as default. NOTE: add support for more HTML tags here. For the present, convert <br> to '\n' convert <p> and </p> to '\n' convert <li> to "\n- "

Parameters
html
Throws
NullPointerException