Class WhitespaceStripper


  • public class WhitespaceStripper
    extends java.lang.Object
    • Field Detail

      • linefeed_space_collapse

        public static final java.util.regex.Pattern linefeed_space_collapse
      • linefeed_to_space

        public static final java.util.regex.Pattern linefeed_to_space
      • tab_to_space

        public static final java.util.regex.Pattern tab_to_space
      • space_collapse

        public static final java.util.regex.Pattern space_collapse
      • space_before_linefeed_collapse

        public static final java.util.regex.Pattern space_before_linefeed_collapse
    • Constructor Detail

      • WhitespaceStripper

        public WhitespaceStripper()
    • Method Detail

      • stripInlineContent

        public static void stripInlineContent​(java.util.List<Styleable> inlineContent)
        Strips whitespace early in inline content generation. This can be done because "whitespage" does not ally to :first-line and :first-letter. For dynamic pseudo-classes we are allowed to choose which properties apply. NOTE: The inlineContent parameter may be modified
        Parameters:
        inlineContent - the inline content to strip the whitespaces on
      • canCollapseThrough

        private static boolean canCollapseThrough​(Styleable styleable)
      • stripTextContent

        private static void stripTextContent​(java.util.List<Styleable> stripped)
      • stripWhitespace

        private static boolean stripWhitespace​(InlineBox iB,
                                               boolean collapseLeading)
        this function strips all whitespace from the text according to the CSS 2.1 spec on whitespace handling. It accounts for the different whitespace settings like normal, nowrap, pre, etc
        Parameters:
        style -
        collapseLeading -
        tc - the TextContent to strip. The text in it is modified.
        Returns:
        whether the next leading space should collapse or not.
      • collapseWhitespaceNormalOrNoWrap

        private static java.lang.String collapseWhitespaceNormalOrNoWrap​(java.lang.String text,
                                                                         boolean collapseLeading)
        Collapse whitespace for normal or no-wrap modes. Much faster (15x in simple testing) than using multiple regular expressions. NOTE: Slightly different behavior to using regular expressions as definition of space characters differ, but I believe this is the correct definition according to CSS specifications.
        Parameters:
        text -
        collapseLeading -
        Returns:
      • collapseWhitespace

        private static java.lang.String collapseWhitespace​(InlineBox iB,
                                                           IdentValue whitespace,
                                                           java.lang.String text,
                                                           boolean collapseLeading)