Issues with LaTeX generated by emacs-jupyter for Symbolics.jl expressions

This might be a really rare combination of techniques.
I’m using Emacs with org-mode’s org-babel to write code blocks. And I’m using emacs-jupyter to connect to Jupyter’s Julia kernel.
When working with Symbolics.jl it prints pretty latex in output. In order to see it rendered in my ORG document I’m choosing :results raw header arguments.

It works fine until I have multiline latex output. Latex get’s wrapped with $$. I suspect emacs-jupyer doing that but not sure where that is happening.
Whats worse it also wraps output with some additional stuff:

\\begin{minipage}{\\textwidth}
\\begin{flushright}\n" data "\n\\end{flushright}
\\end{minipage}")

Eventually what I get in my output is something like this:

\begin{minipage}{\textwidth}
\begin{flushright}
$$ \begin{equation}
\left[
\begin{array}{c}
t_2 + v_{{1}} \lambda^{x}_{{1}} + \left( \lambda^{v}_{{1}} + \mu^{a}_{{1}} \right) \left( \lambda^{v}_{{1}} + \mu^{a}_{{1}} - a\left( t \right) \right) \\
 - t_2 - v_{{2}} \lambda^{x}_{{2}} - \left( \lambda^{v}_{{2}} + \mu^{a}_{{2}} \right) \left( \lambda^{v}_{{2}} + \mu^{a}_{{2}} - a\left( t \right) \right) \\
\end{array}
\right]
\end{equation}
 $$
\end{flushright}
\end{minipage}

Which can’t be rendered properly. If there where no $$ stuff in generated output everything renders fine.

In jupyter-repl there are also issues with rendering multi-line expressions from Symbolics.jl. That’s why I’m suspecting Symbolics.jl in this behavior as well. And it seems the issue again connected to these extra $$ stuff.

I have a little hope someone uses same combination of technologies and ran into same issues. And I’m not sure who is responsible for extra $$ which breaks normal rendering (whether emacs-jupyer responsible for that or Symbolics.jl).

I also should add that SymPy.jl output get’s rendered correctly at the same time with my org-babel code blocks output. And that makes me think that’s Symbolics.jl’s fault. But I have tested on different code with different expressions. So that might be not conclusive.

And also I’ve tried same Symbolics.jl code in Jupyter notebook and Pluto.jl notebook and everything renders fine which makes me believe the issue is with emacs-jupyter.

Posted an issue in emacs-jupyter as my main suspect for that issue.

Eventually the issue seems to be connected to Symbolics.jl. There are some comments in pull request describing that issue and one workaround: call Symbolics.set_default(env=:raw). It works for me well.

There are some attemts to fix issue in emacs as provided in this issue from emacs-jupyer repo. But that didn;t worked for me for some reason.