Summary: This allows you to embed an interactive SageCell into your webpage. Sage is an open source alternative to MathLab, Mathematica, and Maple.
Version: 2013-10-10
Prerequisites: None
Status: Stable
Maintainer: Ben Woodruff
Categories: Math
Users: (view? / edit)
Discussion: SageCell-Talk?

Questions answered by this recipe

Can I embed a sagecell into my wiki so that users can perform mathematical computations on the fly?


You can either copy/paste the following to your config.php file, or you can create a cookbook file and add it there. If someone would like to create a cookbook php file, fix any PHP issues I may have introduced, and upload the file here, feel free.

  Markup('sage', 'directives', '/\\(:sage:\\)/i', '<div class="sage">');
  Markup('sageend', 'directives', '/\\(:sageend:\\)/i', '</div>');
  $HTMLHeaderFmt['SageCell'] = '
   <script src=""></script>
   <script src=""></script>
    $(function () {
        // Make *any* div with class "sage" a Sage cell
        sagecell.makeSagecell({inputLocation: "div.sage",
                               evalButtonText: "Evaluate"});

Feel free to add any CSS you want to change the style.


Just type (:sage:) to start a computation block, and then type (:sageend:) to end one. Here's an example:


Sometimes there are issues if you use comments in your sage code. Using the syntax (:sage:)[@ and @](:sageend:) fixes these issues (I don't know how to program this to be the default).

See also


Ben Woodruff


See discussion at SageCell-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.