How to use the weasyprint.css.utils.single_token function in weasyprint

To help you get started, we’ve selected a few weasyprint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def bleed(token):
    """``bleed`` property validation."""
    keyword = get_keyword(token)
    if keyword == 'auto':
        return 'auto'
    else:
        return get_length(token)
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def image_resolution(token):
    # TODO: support 'snap' and 'from-image'
    return get_resolution(token)
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def min_width_height(token):
    """``min-width`` and ``min-height`` properties validation."""
    # See https://www.w3.org/TR/css-flexbox-1/#min-size-auto
    keyword = get_keyword(token)
    if keyword == 'auto':
        return keyword
    else:
        return length_or_precentage([token])
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def list_style_image(token, base_url):
    """``list-style-image`` property validation."""
    if token.type != 'function':
        if get_keyword(token) == 'none':
            return 'none', None
        parsed_url = get_url(token, base_url)
        if parsed_url:
            if parsed_url[0] == 'url' and parsed_url[1][0] == 'external':
                return 'url', parsed_url[1][1]
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def order(token):
    if token.type == 'number' and token.int_value is not None:
        return token.int_value
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def z_index(token):
    """Validation for the ``z-index`` property."""
    if get_keyword(token) == 'auto':
        return 'auto'
    if token.type == 'number' and token.int_value is not None:
        return token.int_value
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def hyphens(token):
    """Validation for ``hyphens``."""
    keyword = get_keyword(token)
    if keyword in ('none', 'manual', 'auto'):
        return keyword
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def orphans_widows(token):
    """Validation for the ``orphans`` and ``widows`` properties."""
    if token.type == 'number' and token.int_value is not None:
        value = token.int_value
        if value >= 1:
            return value
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def border_width(token):
    """Border, column rule and outline widths properties validation."""
    length = get_length(token, negative=False)
    if length:
        return length
    keyword = get_keyword(token)
    if keyword in ('thin', 'medium', 'thick'):
        return keyword
github Kozea / WeasyPrint / weasyprint / css / validation / properties.py View on Github external
@single_token
def column_count(token):
    """Validation for the ``column-count`` property."""
    if token.type == 'number' and token.int_value is not None:
        value = token.int_value
        if value >= 1:
            return value
    if get_keyword(token) == 'auto':
        return 'auto'