Package com.openhtmltopdf.layout
Class WhitespaceStripper
- java.lang.Object
-
- com.openhtmltopdf.layout.WhitespaceStripper
-
public class WhitespaceStripper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EOL
static char
EOLC
static java.util.regex.Pattern
linefeed_space_collapse
static java.util.regex.Pattern
linefeed_to_space
static java.lang.String
SPACE
static java.util.regex.Pattern
space_before_linefeed_collapse
static java.util.regex.Pattern
space_collapse
static java.util.regex.Pattern
tab_to_space
-
Constructor Summary
Constructors Constructor Description WhitespaceStripper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static boolean
canCollapseThrough(Styleable styleable)
private static java.lang.String
collapseWhitespace(InlineBox iB, IdentValue whitespace, java.lang.String text, boolean collapseLeading)
private static java.lang.String
collapseWhitespaceNormalOrNoWrap(java.lang.String text, boolean collapseLeading)
Collapse whitespace for normal or no-wrap modes.static void
stripInlineContent(java.util.List<Styleable> inlineContent)
Strips whitespace early in inline content generation.private static void
stripTextContent(java.util.List<Styleable> stripped)
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.
-
-
-
Field Detail
-
SPACE
public static final java.lang.String SPACE
- See Also:
- Constant Field Values
-
EOL
public static final java.lang.String EOL
- See Also:
- Constant Field Values
-
EOLC
public static final char EOLC
- See Also:
- Constant Field Values
-
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
-
-
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: TheinlineContent
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)
-
-