def sugartex_replace_all(string):
    """
    Replace all with SugarTeX.
    Runs ``sugartex_preprocess`` then iterates via regex and
    replaces each math between '$...$'.
    """
    string = sugartex_preprocess(string).replace(r'\$', SESSION_ID)
    return re.sub(
        r'(?<=\$)[^$]*(?=\$)',
        lambda m: sugartex.replace(m.group(0)),
        string
    ).replace(SESSION_ID, r'\$')
def sugartex_replace_all ( string ) : string = sugartex_preprocess ( string ) . replace ( r'\$' , SESSION_ID ) return re . sub ( r'(?<=\$)[^$]*(?=\$)' , lambda m : sugartex . replace ( m . group ( 0 ) ) , string ) . replace ( SESSION_ID , r'\$' )
Replace all with SugarTeX.
    Runs ``sugartex_preprocess`` then iterates via regex and
    replaces each math between '$...$'.