org.gjt.sp.util

## Class HtmlUtilities

- java.lang.Object
- - org.gjt.sp.util.HtmlUtilities

    public class HtmlUtilities
    extends java.lang.Object

HTML utility methods for conversion of strings to HTML and highlighting matches in search results. Some of these methods were moved here from HyperSearchResults.HighlightingTree to make them available for plugins.

Since:
  4.4pre1

### Constructor Summary

Constructors
Constructor and Description
`HtmlUtilities()`

### Method Summary

Methods
`static void` `appendString2html(java.lang.StringBuilder sb, java.lang.String s)` Appends a given non-HTML string to an HTML string, translating character entities to the appropriate HTML form.
`static java.lang.String` `highlightString(java.lang.String s, java.lang.String styleTag, java.util.List<java.lang.Integer> ranges)` Creates an HTML presentation of a given string, where selected substrings are highlighted with a given syntax style tag.
`static SyntaxStyle` `parseHighlightStyle(java.lang.String style, java.awt.Font f)` Parses a string specifying a syntax highlight style.
`static java.lang.String` `style2html(java.lang.String prop, java.awt.Font f)` Parses a string specifying a syntax highlight style, and creates an HTML representation for it.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### HtmlUtilities

    public HtmlUtilities()

### Method Detail

#### parseHighlightStyle

    public static SyntaxStyle parseHighlightStyle(java.lang.String style,
                                  java.awt.Font f)

Parses a string specifying a syntax highlight style. The syntax highlight string should be in the same format used to store syntax highlight styles in the properties.

Parameters:
  `style` - The syntax highlight style string.
  `f` - The font to which the syntax style will apply.
Returns:
  The SyntaxStyle object represented by the style string.

#### style2html

    public static java.lang.String style2html(java.lang.String prop,
                              java.awt.Font f)

Parses a string specifying a syntax highlight style, and creates an HTML representation for it. The syntax highlight string should be in the same format used to store syntax highlight styles in the properties.

Parameters:
  `prop` - The syntax highlight style string.
  `f` - The font to which the syntax style will apply.
Returns:
  The HTML representation of the given syntax style.

#### highlightString

    public static java.lang.String highlightString(java.lang.String s,
                                   java.lang.String styleTag,
                                   java.util.List<java.lang.Integer> ranges)

Creates an HTML presentation of a given string, where selected substrings are highlighted with a given syntax style tag.

Parameters:
  `s` - The (non-HTML) string to highlight.
  `styleTag` - The HTML string representing the highlight style.
  `ranges` - The indices of the substrings to highlight, in pairs: The start index of a substring followed by the end index of the substring.
Returns:
  The HTML representation of the string with highlighted substrings.

#### appendString2html

    public static void appendString2html(java.lang.StringBuilder sb,
                         java.lang.String s)

Appends a given non-HTML string to an HTML string, translating character entities to the appropriate HTML form.

Parameters:
  `sb` - The HTML string to which the non-HTML string is appended.
  `s` - The non-HTML string to append.