fix browser detection functions so that they don't break katex when running in node
added support for \def, needs testing and cleanup