Old C Code Transmogrifier*
C, 206 205 bytes

(-1 thanks to ceilingcat)

The newlines are just here for readability.

c,d,q;f(char*s){for(char*S,*T,*t=s;c-63?q=0:q++,d=c&lt;&lt;8|*s,*s?
q&gt;1&amp;&amp;(T=index(S="=/'()!&lt;&gt;-",*s))?t-=2,*s="#\\^[]|{}~"[T-S]:
d&gt;*s&amp;&amp;(T=strstr(S="&gt;:&lt;&gt;%&lt;:%",&amp;d))&amp;&amp;(c="][ }{ # "[T-S])&amp;1?--t,*s=c:0:
0,*t++=c=*s++;);}


Modifies s in place. Tested with GCC and clang on Fedora Workstation, x86, in 32-bit and 64-bit mode.

C is not exactly the best language for golfing here.