INNER CODE UNIT · Python

is_relative

fralau/mkdocs-macros-plugin · mkdocs_macros/context.py:253

def is_relative(url):
    """
    Check whether a url is relative


    >>> urlparse("http://www.google.com")
    ParseResult(scheme='http', netloc='www.google.com', path='', params='', query='', fragment='')
    >>> urlparse("../foo")
    ParseResult(scheme='', netloc='', path='../foo', params='', query='', fragment='')
    """
    p = urlparse(url)
    return (not p.scheme) and p.path


def fix_url(url):
    """
    If url is relative, fix it so that it points to the docs directory.
    This is necessary because relative links in markdown must be adapted

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…