\ProvidesPackage{mathjax}
\let\jax@old@meta=\@meta
\newcommand{\jax@meta}
{\begin{rawhtml}<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>
\end{rawhtml}}
\renewcommand{\@meta}{\jax@old@meta\jax@meta}
%%%Standard
\newcommand{\jax@std}
{\@primitives{mathjax@std}%
\let\textjax\@textjax%
\newenvironment{displayjax}
{\@nostyle\@print{\[}\mathjax}
{\endmathjax\@print{\]}}}%
%%%Auto
\newcommand{\jax@defenv}[1]
{\ifu\csname #1\endcsname\else
\renewenvironment{#1}{\@nostyle\@print{\begin}\{#1\}\mathjax}{\endmathjax\@print{\end}\{#1\}}\fi}
\newcommand{\jax@ensuremath}[1]{\ifmath#1\else\@textjax{#1}\fi}
\newcommand{\jax@auto@redef}
{\let\ensuremath\jax@ensuremath%
\renewcommand{\[}{$$}%
\jax@defenv{math}\jax@defenv{displaymath}%
\jax@defenv{eqnarray}\jax@defenv{eqnarray*}%
\jax@defenv{equation}\jax@defenv{equation*}%
\jax@defenv{align}\jax@defenv{align*}%
\jax@defenv{alignat}\jax@defenv{alignat*}%
\jax@defenv{xalign}\jax@defenv{xxalignat}%
\jax@defenv{gather}\jax@defenv{gather*}%
\jax@defenv{multline}\jax@defenv{multline*}}

\newcommand{\jax@auto}
{\@primitives{mathjax@auto}\AtBeginDocument{\jax@auto@redef}}
%%%Selection
\DeclareOption{auto}{\def\jax@auto@selected{}\jax@auto}
\ProcessOptions*
\ifu\jax@auto@selected\jax@std\else\fi
