Class HtmlUtil

java.lang.Object
org.fife.ui.rsyntaxtextarea.HtmlUtil

public final class HtmlUtil extends Object
Utility methods useful when generating HTML representations of RSTA content.
  • Constructor Details

    • HtmlUtil

      private HtmlUtil()
  • Method Details

    • escapeForHtml

      public static String escapeForHtml(String s, String newlineReplacement, boolean inPreBlock)
      Returns a string with characters that are special to HTML (such as <, > and &) replaced by their HTML escape sequences.
      Parameters:
      s - The input string.
      newlineReplacement - What to replace newline characters with. If this is null, they are simply removed.
      inPreBlock - Whether this HTML will be in within pre tags. If this is true, spaces will be kept as-is; otherwise, they will be converted to " ".
      Returns:
      The escaped version of s.
    • getHexString

      public static String getHexString(Color c)
      Returns a hex string for the specified color, suitable for HTML.
      Parameters:
      c - The color.
      Returns:
      The string representation, in the form "#rrggbb", or null if c is null.
    • getTextAsHtml

      public static String getTextAsHtml(RSyntaxTextArea textArea, int start, int end)
      Returns text from a text area as HTML. Markup is added so that the HTML represents the syntax highlighting in the editor.
      Parameters:
      textArea - The text area.
      start - The start offset.
      end - The end offset.
      Returns:
      The HTML.