def abs_urls(data, target_url, image_url):
def replacer(regex, url):<EOL><INDENT>replacement = r"<STR_LIT>".format(url.rstrip("<STR_LIT:/>"))<EOL>return lambda line: regex.sub(replacement, line, count=<NUM_LIT:1>)<EOL><DEDENT>replacers = [replacer(REGEX_ABS_URLS_TARGET, target_url),<EOL>replacer(REGEX_ABS_URLS_IMAGE, image_url)]<EOL>return [functools.reduce(lambda el, func: func(el), replacers, line)<EOL>for line in data]<EOL>
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.