Questions answered by this recipe
Can I embed a SageMath cell into my wiki so that users can perform mathematical computations on the fly?
Feel free to add any CSS you want to change the style.
(:sage:) to start a computation block, and then type
(:sageend:) to end one. Here's an example:
(:sage:) var('x,y') f(x)=x^2 plot(f,(x,-3,5)) (:sageend:)
(:sage:) directive takes several arguments:
|Label of the eval button (can be any string; must be enclosed in quotes if it has spaces or other special characters)|
|Whether the cell is automatically evaluated on page load, without having to click the eval button; can be |
|What editor to use; can be any of |
|Comma-separated list of languages that the cell can evaluate; see docs for full list (can also be |
|Whether subsequent evaluations replace current ones; can be |
|Comma-separated list of UI elements to hide; see docs for full list||none|
|ID of a linked cell group (see “Linked cells”, below)||none|
(:sage evalButtonText="PROCEED!!" languages=r,python replaceOutput=false :)
(See https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst for more information on these options.)
You can mark a group of Sage cells on the same page as linked cells by adding the
linked=N argument to each of them (where
N is any number, like 1, 2, 17, etc.). You can have any number of linked cell groups; each cell in a linked group must have the same
linked= argument (so you might have several cells with
linked=1, and several others with
linked=2—this would make two linked groups).
See the documentation for more info on linked Sage cells.
The default options may be set in
config.php (before including
$SageCellDefaultArgs = array( "evalButtonText" => "Evaluate", "autoeval" => "false", "editor" => "codemirror", "languages" => "sage", "replaceOutput" => "true", "hide" => "fullScreen" );
(:sage:) (:pastebin-embed n3q5gtX7 raw no-pre:) (:sageend:)
(And similarly with
Change log / Release notes
- 2017-12-31-2: Added support for arguments and linked cells. (SaidAchmiz)
- 2017-12-31: Packaged as a script (
See discussion at SageCell-Talk