Repository: wagtail/wagtail
File: wagtail/users/utils.py (Python)

Code before:
        return False

    if user_to_delete.is_superuser and not current_user.is_superuser:
        # ordinary users may not delete superusers
        return False

    return True


def get_gravatar_url(email, size=50, default_params={"d": "mp"}):
    """
    See https://gravatar.com/site/implement/images/ for Gravatar image options
    Example usage:
    ```python
    # Basic usage
    gravatar_url = get_gravatar_url('user@example.com')

    # Customize size and default image
    gravatar_url = get_gravatar_url(
        'user@example.com',
        size=100,
        default_params={'d': 'robohash', 'f': 'y'}
    )
    Note: If any parameter in `default_params` also exists in the provider URL,
    It will be overridden by the provider URL's query parameter.
    ```
    """

    DEFAULT_GRAVATAR_PROVIDER_URL = "//www.gravatar.com/avatar"

    params = {
        **default_params,
        # requested at retina size by default and scaled down at point of use with css
        "s": int(size) * 2,
    }

    gravatar_provider_url = getattr(
        settings, "WAGTAIL_GRAVATAR_PROVIDER_URL", DEFAULT_GRAVATAR_PROVIDER_URL
    )

    if (not email) or (gravatar_provider_url is None):
        return None

    parsed_url = urlparse(gravatar_provider_url)

    if parsed_url.query:
        parsed_qs = parse_qs(parsed_url.query)
        parsed_qs.pop("s", None)
        parsed_qs.pop("size", None)
        params.update(parsed_qs)


Review comment (suggestion):
move the note to outside the code example.


````suggestion
    ```

    Note: If any parameter in `default_params` also exists in the provider URL,
    It will be overridden by the provider URL's query parameter.
````

Also Markdown code examples will not work here, they need to be RST.

See a good example here https://github.com/wagtail/wagtail/blob/94d3557cea99a5674397ad7db29529de9dd131c5/wagtail/models/__init__.py#L873-L898

Code after:
        return False

    if user_to_delete.is_superuser and not current_user.is_superuser:
        # ordinary users may not delete superusers
        return False

    return True


def get_gravatar_url(email, size=50, default_params={"d": "mp"}):
    """
    See https://gravatar.com/site/implement/images/ for Gravatar image options.

    Example usage:

    .. code-block:: python

        # Basic usage
        gravatar_url = get_gravatar_url('user@example.com')

        # Customize size and default image
        gravatar_url = get_gravatar_url(
            'user@example.com',
            size=100,
            default_params={'d': 'robohash', 'f': 'y'}
        )

    Note:
        If any parameter in ``default_params`` also exists in the provider URL,
        it will be overridden by the provider URL's query parameter.
    """

    gravatar_provider_url = getattr(
        settings, "WAGTAIL_GRAVATAR_PROVIDER_URL", "//www.gravatar.com/avatar"
    )

    if (not email) or (gravatar_provider_url is None):
        return None

    parsed_url = urlparse(gravatar_provider_url)

    params = {
        **default_params,
        **(parse_qs(parsed_url.query or "")),
        # requested at retina size by default and scaled down at point of use with css
        "s": int(size) * 2,
    }

    email_hash = safe_md5(
        email.lower().encode("utf-8"), usedforsecurity=False
    ).hexdigest()