java.lang.Object
org.gjt.sp.util.HtmlUtilities
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
- Version:
- $Id: $
- Author:
- Shlomy Reinstein
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendString2html
(StringBuilder sb, String s) Appends a given non-HTML string to an HTML string, translating character entities to the appropriate HTML form.static String
highlightString
(String s, String styleTag, List<Integer> ranges) Creates an HTML presentation of a given string, where selected substrings are highlighted with a given syntax style tag.static SyntaxStyle
parseHighlightStyle
(String style, Font f) Parses a string specifying a syntax highlight style.static String
style2html
(String prop, Font f) Parses a string specifying a syntax highlight style, and creates an HTML representation for it.
-
Constructor Details
-
HtmlUtilities
public HtmlUtilities()
-
-
Method Details
-
parseHighlightStyle
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
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
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
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.
-