/** * Escapes reserved HTML characters in the given string. * <p> * <b>Warning:</b> Does not preserve whitespace. * * @param content the input string * @return the string with escaped characters * * @see #convertToHTMLContentWithWhitespace(String) for use in browsers * @see #addPreFormatted(StringBuffer, String) for rendering with an {@link HTML2TextReader} */ public static String convertToHTMLContent(String content) { content= replace(content, '&', "&"); //$NON-NLS-1$ content= replace(content, '"', """); //$NON-NLS-1$ content= replace(content, '<', "<"); //$NON-NLS-1$ return replace(content, '>', ">"); //$NON-NLS-1$ }
/** * Escapes reserved HTML characters in the given string. * <p> * <b>Warning:</b> Does not preserve whitespace. * * @param content the input string * @return the string with escaped characters * * @see #convertToHTMLContentWithWhitespace(String) for use in browsers * @see #addPreFormatted(StringBuilder, String) for rendering with an {@link HTML2TextReader} */ public static String convertToHTMLContent(String content) { content= replace(content, '&', "&"); //$NON-NLS-1$ content= replace(content, '"', """); //$NON-NLS-1$ content= replace(content, '<', "<"); //$NON-NLS-1$ return replace(content, '>', ">"); //$NON-NLS-1$ }
/** * Escapes reserved HTML characters in the given string * and returns them in a way that preserves whitespace in a browser. * <p> * <b>Warning:</b> Whitespace will not be preserved when rendered with an {@link HTML2TextReader} * (e.g. in a {@link DefaultInformationControl} that renders simple HTML). * @param content the input string * @return the processed string * * @see #addPreFormatted(StringBuffer, String) * @see #convertToHTMLContent(String) * @since 3.7 */ public static String convertToHTMLContentWithWhitespace(String content) { content= replace(content, '&', "&"); //$NON-NLS-1$ content= replace(content, '"', """); //$NON-NLS-1$ content= replace(content, '<', "<"); //$NON-NLS-1$ content= replace(content, '>', ">"); //$NON-NLS-1$ return "<span style='white-space:pre'>" + content + "</span>"; //$NON-NLS-1$ //$NON-NLS-2$ }
/** * Escapes reserved HTML characters in the given string and returns them in a way that preserves * whitespace in a browser. * <p> * <b>Warning:</b> Whitespace will not be preserved when rendered with an * {@link HTML2TextReader} (e.g. in a {@link DefaultInformationControl} that renders simple * HTML). * * @param content the input string * @return the processed string * * @see #addPreFormatted(StringBuilder, String) * @see #convertToHTMLContent(String) * @since 3.7 */ public static String convertToHTMLContentWithWhitespace(String content) { content= replace(content, '&', "&"); //$NON-NLS-1$ content= replace(content, '"', """); //$NON-NLS-1$ content= replace(content, '<', "<"); //$NON-NLS-1$ content= replace(content, '>', ">"); //$NON-NLS-1$ return "<span style='white-space:pre'>" + content + "</span>"; //$NON-NLS-1$ //$NON-NLS-2$ }