I have a bunch of Jupyter Notebooks with equations written in LaTex. I know that I can convert the notebook to HTML as follows.
jupyter nbconvert --to html --template basic test.ipynb test.html
However, the LaTex markup are preserved. For example, if I have $y = w'x$
, then that still shows up in the output HTML. I want to get this generated HTML into WordPress (basically, copy/paste), but WordPress delimits LaTex like this $latex y = w'x$
.
How can I use perl
or sed
(or anything else) to convert $y = w'x
to $latex y = w'x$
?
I know I can just write a program to do it, but I think that's an overkill because I am sure these available command line tools can do it to. Additionally, any tool that is available on both Windows and Mac/Linux would be a bonus, since I work on both environment types, and do not want to have to resort to a *nix like environment to do this conversion (though, Windows does have Windows Linux Subsystem now, so I guess that might be ok if it's just a Linux tool).
I tried to modify this sed
expression from this post (on Mac), but it did not work.
sed -e ' /\$\$/{s/\$\$/{\$latex }/;:a;N;/\$\$/!ba;s/\$\$/{\$}/};s/^\(\$\)\(.*\)\(\$\)$/{\$latex }\2{\$}/' test.html
unexpected EOF (pending }'s)