def supscr(text=None):
    """
     | supscr - add superscript text formatting for ** and ^
     | This is an internal routine used in titles and colour bars
     | and not used by the user.
     | text=None - input text

     :Returns:
      Formatted text
     |
     |
     |
     |
     |
     |
     |
    """
    if text is None:
        errstr = '\n supscr error - supscr must have text input\n'
        raise Warning(errstr)
    tform = ''
    sup = 0
    for i in text:
        if i == '^':
            sup = 2
        if i == '*':
            sup = sup + 1
        if sup == 0:
            tform = tform + i
        if sup == 1:
            if i not in '*':
                tform = tform + '*' + i
                sup = 0
        if sup == 3:
            if i in '-0123456789':
                tform = tform + i
            else:
                tform = tform + '}$' + i
                sup = 0
        if sup == 2:
            tform = tform + '$^{'
            sup = 3
    if sup == 3:
        tform = tform + '}$'
    tform = tform.replace('m2', 'm$^{2}$')
    tform = tform.replace('m3', 'm$^{3}$')
    tform = tform.replace('m-2', 'm$^{-2}$')
    tform = tform.replace('m-3', 'm$^{-3}$')
    tform = tform.replace('s-1', 's$^{-1}$')
    tform = tform.replace('s-2', 's$^{-2}$')
    return tform
