def is_whitespace(box, _has_non_whitespace=re.compile('\\S').search):
    """Return True if ``box`` is a TextBox with only whitespace."""
    return isinstance(box, boxes.TextBox) and not _has_non_whitespace(box.text)
Return True if ``box`` is a TextBox with only whitespace.
weasyprint/formatting_structure/build.py