Class HtmlUtil


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

      Constructors 
      Modifier Constructor Description
      private HtmlUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escapeForHtml​(java.lang.String s, java.lang.String newlineReplacement, boolean inPreBlock)
      Returns a string with characters that are special to HTML (such as <, > and &) replaced by their HTML escape sequences.
      static java.lang.String getHexString​(java.awt.Color c)
      Returns a hex string for the specified color, suitable for HTML.
      static java.lang.String getTextAsHtml​(RSyntaxTextArea textArea, int start, int end)
      Returns text from a text area as HTML.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HtmlUtil

        private HtmlUtil()
    • Method Detail

      • escapeForHtml

        public static java.lang.String escapeForHtml​(java.lang.String s,
                                                     java.lang.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 java.lang.String getHexString​(java.awt.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 java.lang.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.