I want to use sed to replace something like $some latex$ or
$$
some latex
$$
with {% math %}some latex {% endmath %} or
{% math %}
some latex
{% endmath %}
I try sed to solve this problem but a command like
sed -e 's/\$\([^\$]\{1,\}\)\$/{% math %}\1{% endmath %}/g' filename
doesn't work for $some latex$ and I don't know how to deal with multi-line. How can I do this?