Define the syntax within native MathML rendering switching between environments as well as defining a chemical environment.
Make sure the syntax is compatible or in sync with the Restbase math processing.
Implement Testcases for these enviroment switch syntax.
Implement enviroment switches in MathML rendering.
Testing page for this cases:
https://en.wikipedia.beta.wmflabs.org/wiki/Help:MathTestCustomChem
The current (Restbase) behaviour for environment settings by TeX syntax can be seen here:
https://meta.wikimedia.org/wiki/Help:Displaying_a_formula#Chemistry
Current conclusion from the documents and testing page:
Neither "$" or "begin/end{math}" is supported in escaping a math environment.