Convert superscripts to MathJax CGCC hasn't always had MathJax. Back in the dark ages, it would have been necessary to write \$x^2\$ as x² (the horror!). In this challenge, you will be given some math which may include superscripts, and you should convert it to MathJax.
Input:
Input will consist of one or more letters a to z, some with superscripts. Answers may choose to handle only upper or lower case, or both.
Examples of inputs would be x, x², xy², x²y², or x²yz. There will never be duplicates of a letter (so xx or x²zx won't be given), but you cannot assume the superscripts or letters are in any particular order. The first character in the input will never be a superscript.
Superscripts consist of the characters ¹, ², ³, ⁴, ⁵, ⁶, ⁷, ⁸, ⁹, and ⁰. These can be joined into multi-digit superscripts, like x²¹ (\$x^{21}\$). You can assume ⁰ or ¹ are never given as superscripts, and there will not be leading ⁰s.
Output:
Output should consist of a MathJax representation of the input. This must start and finish with \$.
Characters without superscripts can be written as themselves; xyz would simply become \$xyz\$. Characters with superscripts should be followed by ^, then the superscript written with normal digits and wrapped in {}. For example, x²¹z⁴⁸⁸ would become \$x^{21}z^{488}\$. Optionally, single digit superscripts can be written without the {}. For example, x² could be either \$x^{2}\$ or \$x^2\$.
Test cases:
x           \$x\$
xyz         \$xyz\$
x²          \$x^{2}\$ OR \$x^2\$
x²¹         \$x^{21}\$
x²yz²       \$x^{2}yz^{2}\$ OR \$x^2yz^2\$
xy¹¹z       \$xy^{11}z\$
x⁴          \$x^{4}\$ OR \$x^4\$
x⁶⁰         \$x^{60}\$

Other:
This is code-golf, shortest answer (in bytes) per language wins!
Husk, 43 41 40 bytes
`JD;&quot;¦$&quot;ṁ?Iȯ:'^`J&quot;{}&quot;ṁos€&quot;¹²³⁴⁵⁶⁷⁸⁹&quot;Λ√ġ√

Try it online!
The superscripts are 1 byte each since they're in Husk's codepage.
I wanted to replace +₁+₁ with S+`+&quot;¦$&quot; but it didn't work for some reason.. :(
-2 bytes borrowing the indexing idea from hyper-neutrino.
-1 byte from Leo.
Explanation
`JD;&quot;¦$&quot;ṁ?Iȯ`:'}+&quot;^{&quot;ṁos€&quot;¹..⁹&quot;Λ√ġ√
                              ġ√ group on alphabets
     ṁ                           map and concatenate with:
      ?                            if:
                            Λ√      the group is alphabetical
       I                             leave as is
        ȯ`:'}+&quot;^{&quot;ṁos€&quot;¹..⁹&quot;        otherwise:
                  ṁȯ                  map and concat each char to:
                     €&quot;¹..⁹&quot;           index in ¹..⁹(0 if not present)
                    s                  cast to string
             +&quot;^{&quot;                    prepend &quot;^{&quot;
         `:'}                         append '{'
`JD;&quot;¦$&quot;                            surround the final string with &quot;\$&quot;