My goal is to write a simple function that can do the following:
Staring with an expression that looks like
$$ x = y $$
$$ y = z $$
$$ z = x $$
(There can more lines of such equations)
I want to write a elisp function that when I run it after selecting this region, I get the following
\begin{align}
x = y \\
y = z \\
z = x
\end{align}
I need to do a conditional replace on $$
depending on whether it is near the beginning of the line or the end of the line. Moreover, I also need to do not replace the last $$
with \\
but with \end{align}
. I am new to elisp and I could not figure out how to do a conditional replace and also how to restrict the replace to the region I selected.
Any help is greatly appreciated.