def _inline_svg(svg: str) -> str:
    """Encode SVG to be used inline as part of a data URI.

    Replacements are not complete, but sufficient for this case.

    See https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
    for details.
    """
    replaced = (
        svg
        .replace('\n', '%0A')
        .replace('#', '%23')
        .replace('<', '%3C')
        .replace('>', '%3E')
        .replace('"', '\'')
    )

    return 'data:image/svg+xml,' + replaced