Class HTMLFormatter


  • public class HTMLFormatter
    extends Object
    Utility class which is used to substitute text containing various links (http://, mailto:, ftp: and so on) with actual HTML link and line feeds with <br/> tag.

    Rewritten to fix TW-8635.

    • Constructor Detail

      • HTMLFormatter

        public HTMLFormatter()
    • Method Detail

      • format

        public static String format​(String text,
                                    @NotNull
                                    javax.servlet.jsp.JspContext context)
        Searches for plain links in specified text and returns the same text with links transformed to HTML links (<a href=""></a>).
        Parameters:
        text - text containing links
        context - JSP context
        Returns:
        text with transformed links
      • format

        public static String format​(String text,
                                    @NotNull
                                    WebContext context)
        Searches for plain links in specified text and returns the same text with links transformed to HTML links (<a href=""></a>).
        Parameters:
        text - text containing links
        context - context for the transformation
        Returns:
        text with transformed links
        Since:
        2018.1
      • formatMultiLine

        @NotNull
        public static String formatMultiLine​(@Nullable
                                             String text)
        Escapes the text for HTML and transforms line feeds with <br>s.
        Parameters:
        text - text to format
        Returns:
        a formatted text
        Since:
        7.0
      • formatMultiLine

        @NotNull
        public static String formatMultiLine​(@Nullable
                                             String text,
                                             boolean escape)
        Transforms line feeds with <br>s.
        Parameters:
        text - text to format
        escape - true if text should be escaped first
        Returns:
        a formatted text
        Since:
        7.1.2, 8.0
      • addTransformLinkWithTextPattern

        public static void addTransformLinkWithTextPattern()
      • addTransformLinkPattern

        public static void addTransformLinkPattern()