def capitalize(text):
    """Capitalize words according to CSS’s "text-transform: capitalize"."""
    letter_found = False
    output = ''
    for letter in text:
        category = unicodedata.category(letter)[0]
        if not letter_found and category in ('L', 'N'):
            letter_found = True
            letter = letter.upper()
        elif category == 'Z':
            letter_found = False
        output += letter
    return output
Capitalize words according to CSS’s "text-transform: capitalize".
weasyprint/formatting_structure/build.py