F̲o̲r̲m̲a̲t̲t̲e̲r̲ (*Unicode* **Markdown** __Formatter__) If you cannot see this post, you can use this image

Your task is to create a markdown parser that outputs Unicode. It should support , , , and ̲̲̲̲̲̲̲̲̲. 

Every alphabetical character should be converted into Math Sans. This includes the characters before an underline character.

Underlines: Add a ̲ character (code point 818) after each character. Underlines can be combined with anything else.

There should be no way to escape a control character. 

The following combinations should be supported:

 (code point 120224 to 120275 Math Sans)

`   ` (120432 to 120483 Math Monospace)

*  * (120328 to 120379 Math Sans Italic)

**  ** (120276 to 120327 Math Sans Bold)

***  *** (120380 to 120431 Math Sans Bold Italic)

__ ̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲ __ (818 Math Sans with Combining Low Line after each character)

__` ̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲̲ `__ (Math Sans Monospace with Combining Low Line)

Underline should also support Math Sans Italic, Math Sans Bold, and Math Sans Bold Italic

The final output should not contain the characters used to format the text.

Nesting

Some things can be nested. Underlines can nest with any character and can be put in the inside or outside of another control character. Both of these will have an underline

**Underlines __inside the bold__**
__Bold **inside the underline**__


Other things such as bold, monospace, bold italic, and italic can't nest because there are no charactes for it

**This is `not valid` input and will***never be given*


Ambiguous Formatting Characters

Formatting characters that can be ambiguous will never be given. ** is valid because it is bold, but **** will never be given because it is undefined.

At the end of formatting characters, there will always be another character between the next formatting delimiter of the same character. *format***ing** will not be given because there should be a character before the next *format* **ing** delimiter using *s, however *format*__ing__ could be given because they are different characters used in the delimiter. 

**Which is bold ***and which is italic?* &lt;-- Invalid, will never be given
**Oh I see** *now.* &lt;-- Valid


Escaping

Nothing can escape. There is no way to use any of the control characters except for a singular underscore

*There is no way to put a * in the text, not even \* backslashes* &lt;-- All of the asterisks will be italic

Even __newlines
don't interrupt__ formatting &lt;-- newlines don't interrupt will all be underlined

Because the singular _underscore is not a formatting character, it_is allowed_ and will not be removed


Example I/O

Example I

*This* is_a **test** of __the ***markdown*** `parser`__ Multi-line `__should
be__ supported`. Nothing `can\` escape.


Example O

 _   ̲̲̲ ̲̲̲̲̲̲̲̲̲ ̲̲̲̲̲̲̲ - ̲̲̲̲̲̲
̲̲̲ .  \ .


This input is not valid and it doesn't matter what your program outputs:

*This **is not valid** input* because it nests italic and bold

*Neither `is this`* because it nests italic and monospace

*This***Is not valid** Either because it can be interpreted different ways


As this is code-golf, the shortest solution in bytes wins.
Stax, 75 73 74 70 bytes

Ç╜ÿPÜV►♀b7╛i┴?τ\⌂:Té√╖■♠(µ`ómƒÜKx▬∙═τ½εxÅr∩!E#î⌡╕B┴zäÅéë┘S²↔óh₧≡6ÿ╖iô├


Run and debug it online

The basic approach is store the 4 types of formatting in a bit field, and then get the correct character offset from a lookup using the integer value.  Only 8 values are in the lookup.  The high bit denoting underline is handled separately.

Here's a commented ungolfed version.

m                       Map mode: for each line of input, 
                            run the rest of the program, then output
"\*\*|__|."|F           Find all regex matches using pattern. This splits the string into 
                            individual characters except for ** and __, which stay together.
                            These will be called "atoms" of the input.
{                       begin a block
  VAVa+                 Construct "ABC..XYZabc..xyz"
  "_*``_****__"_I       Get the index of the current atom in "_*`_****__"
  0|MY                  Take the maximum with zero, then store in register y.
                            This gives {*: 1, `: 2, **: 4, __: 8} and 0 for all else. 
  x|^X                  Xor with the x register and write back. It stores bitflags for 4 modes.
  "&amp;6mU*9*9 0E*9 !"!@   Index into codepoint lookup table using x.
  c52+|r                Build range of 52 consecutive values starting at codepoint.
  \$                    Build translation string by combination with the alphabetic string.
  |t                    Perform translation on the current atom.
  818+                  Add codepoint 818 to the current atom.
  x8&lt;T                  Remove it again if x&lt;8.  This is iff underline mode is off.
  y!*                   Multiply by the logical not of y.  If the atom is for formatting, 
                        this eliminates output for this atom
m                       map over atoms using the enclosed block


Run this one