I have started putting Mathematica code in the annotations portion of on my website, but right now I am editing the code manually. Is there an more robust automated way to do this? Example HTML page shows annotations in menu.

<!doctype html><script type="text/x-mathjax-config">
  MathMenu: {
    semanticsAnnotations: {
</script><script type="text/javascript" async
<math xmlns='http://www.w3.org/1998/Math/MathML'>
 <annotation encoding="Mathematica">Sin[x]</annotation>

I am just looking to automate the generation of the MathML portion of the code.

  • 2
    $\begingroup$ Notice that without your answer it is not very clear what kind of answer would you like to get. What can be a possible input etc. $\endgroup$ – Kuba Aug 11 '18 at 6:53

Here is a rather lazy way that works okay for regular input equations but needs some editing to work with any cell.

equation = Sin[x];
"<math xmlns='http://www.w3.org/1998/Math/MathML'><semantics>" <> 
     ExportString[equation, "MathML"], "\n"], -1], 1], 
  ""] <> "<annotation encoding=\"Mathematica\">" <> 
   equation] <> "</annotation>" <> "</semantics></math>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.