Filter for a list of reStructuredText lines that replaces relative
    link targets and image sources by absolute URLs given the base
    URLs that should be used (``target_url`` for link targets,
    ``image_url``for image sources). Returns a list of strings.

def abs_urls(data, target_url, image_url):
    """
    Filter for a list of reStructuredText lines that replaces relative
    link targets and image sources by absolute URLs given the base
    URLs that should be used (``target_url`` for link targets,
    ``image_url``for image sources). Returns a list of strings.
    """
    def replacer(regex, url):
        replacement = r"\1 {0}/\2".format(url.rstrip("/"))
        return lambda line: regex.sub(replacement, line, count=1)
    replacers = [replacer(REGEX_ABS_URLS_TARGET, target_url),
                 replacer(REGEX_ABS_URLS_IMAGE, image_url)]
    return [functools.reduce(lambda el, func: func(el), replacers, line)
            for line in data]