code: 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'\$')
docs: Replace all with SugarTeX.
      Runs ``sugartex_preprocess`` then iterates via regex and
      replaces each math between '$...$'.