def latex_safe(s, url_check=True, wrapper='url'):
    "Make string latex safe\n\n    Parameters\n    ----------\n    s : str\n    url_check : bool, optional\n        If True check for URLs and wrap them, if False check for URL but don't\n        wrap, defaults to True\n    wrapper : str, optional\n        The wrapper for wrapping urls defaults to url\n    "
    if (not s):
        return s
    if url_check:
        url_search = HTTP_RE.search(s)
        if url_search:
            url = '{start}\\{wrapper}{{{s}}}{end}'.format(start=latex_safe(s[:url_search.start()]), end=latex_safe(s[url_search.end():]), wrapper=wrapper, s=latex_safe_url(s[url_search.start():url_search.end()]))
            return url
    return s.replace('&', '\\&').replace('$', '\\$').replace('#', '\\#').replace('_', '\\_')
Make string latex safe

Parameters
----------
s : str
url_check : bool, optional
    If True check for URLs and wrap them, if False check for URL but don't
    wrap, defaults to True
wrapper : str, optional
    The wrapper for wrapping urls defaults to url
def latex_safe(s, url_check=True, wrapper='url'):
    "Make string latex safe\n\n    Parameters\n    ----------\n    s : str\n    url_check : bool, optional\n        If True check for URLs and wrap them, if False check for URL but don't\n        wrap, defaults to True\n    wrapper : str, optional\n        The wrapper for wrapping urls defaults to url\n    "
    if (not s):
        return s
    if url_check:
        url_search = HTTP_RE.search(s)
        if url_search:
            url = '{start}\\{wrapper}{{{s}}}{end}'.format(start=latex_safe(s[:url_search.start()]), end=latex_safe(s[url_search.end():]), wrapper=wrapper, s=latex_safe_url(s[url_search.start():url_search.end()]))
            return url
    return s.replace('&', '\\&').replace('$', '\\$').replace('#', '\\#').replace('_', '\\_')