I found a new workaround. It works well for me as the same as when I use the math
shortcode which includes {{ .Inner }}
.
But, this will break other elements, is not practical. We need the goldmark-mathjax extension to solve this problem.
Template:
{{ $content := $.Content | replaceRE "\\<br>" "\\" }}
{{ $content | safeHTML }}
Markdown:
{{< math >}}
\begin{vmatrix}a & b\\
c & d
\end{vmatrix}
{{< /math >}}
$$
\begin{vmatrix}a & b\\
c & d
\end{vmatrix}
$$