A Cell.

A cell is a single input/output block. Worksheets are built out of a list of cells.

class sage.server.notebook.cell.Cell(id, input, out, worksheet)
__cmp__(right)

EXAMPLES:

sage: C1 = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C2 = sage.server.notebook.cell.Cell(0, '3+2', '5', None)
sage: C3 = sage.server.notebook.cell.Cell(1, '2+3', '5', None)
sage: C1 == C1
True
sage: C1 == C2
True
sage: C1 == C3
False
__init__(id, input, out, worksheet)

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C == loads(dumps(C))
True
__repr__()

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None); C
Cell 0; in=2+3, out=5
_directory_name()

Returns a string of the directory associated to self.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', W)
sage: C._directory_name()
'.../worksheets/sage/0/cells/0'
sage: import shutil; shutil.rmtree(nb.directory())
cell_output_type()

Returns the cell output type.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.cell_output_type()
'wrap'
sage: C.set_cell_output_type('nowrap')
sage: C.cell_output_type()
'nowrap'
changed_input_text()

Returns the changed input text for the cell. If there was any changed input text, then it is reset to ” before this method returns.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.changed_input_text()
''
sage: C.set_changed_input_text('3+3')
sage: C.input_text()
'3+3'
sage: C.changed_input_text()
'3+3'
sage: C.changed_input_text()
''
sage: C.version()
0
cleaned_input_text()

Returns the input text with all of the percent directives removed. If the cell is interacting, then the interacting text is returned.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '%hide\n%maxima\n2+3', '5', None)
sage: C.cleaned_input_text()
'2+3'
computing()

Returns True if self is in its worksheet’s queue.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.computing()
False
sage: import shutil; shutil.rmtree(nb.directory())
delete_files()

Deletes all of the files associated with this cell.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, 'plot(sin(x),0,5)', ", W)sage: 
C.evaluate()
sage: W.check_comp(wait=9999)
('d', Cell 0; in=plot(sin(x),0,5), out=
<html><font color='black'><img src='cell://sage0.png'></font></html>
<BLANKLINE>
)
sage: C.files()
['sage0.png']
sage: C.delete_files()
sage: C.files()
[]
delete_output()

Delete all output in this cell.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None); C
Cell 0; in=2+3, out=5
sage: C.delete_output()
sage: C
Cell 0; in=2+3, out=
directory()

Returns the directory associated to self. If the directory doesn’t already exist, then this method creates it.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.directory()
'.../worksheets/sage/0/cells/0'
sage: import shutil; shutil.rmtree(nb.directory())
doc_html(wrap=None, div_wrap=True, do_print=False)
Modified version of self.html for the doc browser. This is a hack and needs to be improved. The problem is how to get the documentation html to display nicely between the example cells. The type setting (jsMath formatting) needs attention too.
edit_text(ncols=0, prompts=False, max_out=None)

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.edit_text()
'{{{id=0|\n2+3\n///\n5\n}}}'
evaluate(introspect=False, time=None, username=None)

INPUT:

  • username - name of user doing the evaluation
  • time - if True return time computation takes
  • introspect - either False or a pair [before_cursor, after_cursor] of strings.

EXAMPLES: We create a notebook, worksheet, and cell and evaluate it in order to compute 3^5:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: W.edit_save('Sage\n{{{\n3^5\n}}}')
sage: C = W.cell_list()[0]; C
Cell 0; in=3^5, out=
sage: C.evaluate(username='sage')
sage: W.check_comp(wait=9999)
('d', Cell 0; in=3^5, out=
243
)
sage: C
Cell 0; in=3^5, out=
243        
sage: import shutil; shutil.rmtree(nb.directory())
evaluated()

Return True if this cell has been successfully evaluated in a currently running session.

This is not about whether the output of the cell is valid given the input.

OUTPUT:

  • bool - whether or not this cell has been evaluated in this session

EXAMPLES: We create a worksheet with a cell that has wrong output:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: W.edit_save('Sage\n{{{\n2+3\n///\n20\n}}}')
sage: C = W.cell_list()[0]
sage: C
Cell 0; in=2+3, out=
20

We re-evaluate that input cell:

sage: C.evaluate()
sage: W.check_comp(wait=9999)
('d', Cell 0; in=2+3, out=
5
)

Now the output is right:

sage: C
Cell 0; in=2+3, out=
5

And the cell is considered to have been evaluated.

sage: C.evaluated()
True
sage: import shutil; shutil.rmtree(nb.directory())
files()

Returns a list of all the files in self’s directory.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, 'plot(sin(x),0,5)', ", W)sage: 
C.evaluate()
sage: W.check_comp(wait=9999)
('d', Cell 0; in=plot(sin(x),0,5), out=
<html><font color='black'><img src='cell://sage0.png'></font></html>
<BLANKLINE>
)
sage: C.files()
['sage0.png']
sage: import shutil; shutil.rmtree(nb.directory())
files_html(out)
has_output()

Returns True if there is output for this cell.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.has_output()
True
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '', None)
sage: C.has_output()
False
html(wrap=None, div_wrap=True, do_print=False)
html_in(do_print=False, ncols=80)

Returns the HTML code for the input of this cell.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: print C.html_in()
<div class="insert_new_cell" id="insert_new_cell_0"...</a>
html_new_cell_after()

Returns the HTML code for inserting a new cell after self.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: print C.html_new_cell_after()
<div class="insert_new_cell" id="insert_new_cell_0">...
html_new_cell_before()

Returns the HTML code for inserting a new cell before self.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: print C.html_new_cell_before()
<div class="insert_new_cell" id="insert_new_cell_0">...
html_out(ncols=0, do_print=False)
id()

Returns the id of self.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.id()
0
input_text()

Returns self’s input text.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.input_text()
'2+3'
interrupt()

Record that the calculation running in this cell was interrupted.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.interrupt()
sage: C.interrupted()
True
sage: C.evaluated()
False
sage: import shutil; shutil.rmtree(nb.directory())
interrupted()

Returns True if the evaluation of this cell has been interrupted.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.interrupt()
sage: C.interrupted()
True
sage: import shutil; shutil.rmtree(nb.directory())
introspect()

TODO: Figure out what the __introspect method is for and write a better doctest.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.introspect()
False
sage: C.set_introspect("a", "b")
sage: C.introspect()
['a', 'b']
introspect_html()
is_asap()

Return True if this is an asap cell, i.e., evaluation of it is done as soon as possible.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_asap()
False
sage: C.set_asap(True)
sage: C.is_asap()
True
is_auto_cell()

Returns True if self is an auto cell.

An auto cell is a cell that is automatically evaluated when the worksheet starts up.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_auto_cell()
False
sage: C = sage.server.notebook.cell.Cell(0, '#auto\n2+3', '5', None)
sage: C.is_auto_cell()
True
is_html()

Returns True if this is an HTML cell. An HTML cell whose system is ‘html’ and is typically specified by %html.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, "%html\nTest HTML", None, None)
sage: C.system()
'html'
sage: C.is_html()
True
sage: C = sage.server.notebook.cell.Cell(0, "Test HTML", None, None)
sage: C.is_html()
False
is_interacting()
Returns True
is_interactive_cell()

Return True if this cell contains the use of interact either as a function call or a decorator.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "@interact\ndef f(a=slider(0,10,1,5):\n    print a^2")
sage: C.is_interactive_cell()
True
sage: C = W.new_cell_after(C.id(), "2+2")
sage: C.is_interactive_cell()
False
sage: import shutil; shutil.rmtree(nb.directory())
is_last()

Returns True if self is the last cell in the worksheet.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2"); C
Cell 1; in=2^2, out=
sage: C.is_last()
True
sage: C = W.get_cell_with_id(0)
sage: C.is_last()
False
sage: import shutil; shutil.rmtree(nb.directory())
is_no_output()

Return True if this is an no_output cell, i.e., a cell for which we don’t care at all about the output.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_no_output()
False
sage: C.set_no_output(True)
sage: C.is_no_output()
True
next_id()

Returns the id of the next cell in the worksheet associated to self. If self is not in the worksheet or self is the last cell in the cell_list, then the id of the first cell is returned.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C = W.get_cell_with_id(0)
sage: C.next_id()
1
sage: C = W.get_cell_with_id(1)
sage: C.next_id()
0
sage: import shutil; shutil.rmtree(nb.directory())
notebook()

Returns the notebook object associated to self.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.notebook() is nb
True
sage: import shutil; shutil.rmtree(nb.directory())
output_html()
output_text(ncols=0, html=True, raw=False, allow_interact=True)
parse_html(s, ncols)
parse_percent_directives()

Returns a string which consists of the input text of this cell with the percent directives at the top removed. As it’s doing this, it computes a list of all the directives and which system (if any) the cell should be run under.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '%hide\n%maxima\n2+3', '5', None)
sage: C.parse_percent_directives()
'2+3'
sage: C.percent_directives()
['hide', 'maxima']
percent_directives()

Returns a list of all the percent directives that appear in this cell.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '%hide\n%maxima\n2+3', '5', None)
sage: C.percent_directives()
['hide', 'maxima']
plain_text(ncols=0, prompts=True, max_out=None)

Returns the plain text version of self.

TODO: Add more comprehensive doctests.

process_cell_urls(x)
sage()

TODO: Figure out what exactly this does.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.sage() is None
True
set_asap(asap)

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_asap()
False
sage: C.set_asap(True)
sage: C.is_asap()
True
set_cell_output_type(typ='wrap')

Sets the cell output type.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.cell_output_type()
'wrap'
sage: C.set_cell_output_type('nowrap')
sage: C.cell_output_type()
'nowrap'
set_changed_input_text(new_text)

Note that this does not update the version of the cell. This is typically used for things like tab completion.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.set_changed_input_text('3+3')
sage: C.input_text()
'3+3'
sage: C.changed_input_text()
'3+3'
set_id(id)

Sets the id of self to id.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.set_id(2)
sage: C.id()
2
set_input_text(input)

Sets the input text of self to be the string input.

TODO: Add doctests for the code dealing with interact.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.evaluate()
sage: W.check_comp(wait=9999)
('d', Cell 1; in=2^2, out=
4
)
sage: C.version()
0
sage: C.set_input_text('3+3')
sage: C.input_text()
'3+3'
sage: C.evaluated()
False
sage: C.version()
1
sage: import shutil; shutil.rmtree(nb.directory())
set_introspect(before_prompt, after_prompt)

TODO: Figure out what the __introspect method is for and write a better doctest.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.set_introspect("a", "b")
sage: C.introspect()
['a', 'b']
set_introspect_html(html, completing=False, verbose=False)
If verbose is True, print verbose output about notebook introspection to the command-line. However, the argument verbose is not easily accessible now – if you need to debug, you have to edit this file, changing its value to True, and run ‘sage -b’.
set_is_html(v)

Sets whether or not this cell is an HTML cell.

This is called by check_for_system_switching in worksheet.py.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_html()
False
sage: C.set_is_html(True)
sage: C.is_html()
True
set_no_output(no_output)

Sets whether or not this is an no_output cell, i.e., a cell for which we don’t care at all about the output.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_no_output()
False
sage: C.set_no_output(True)
sage: C.is_no_output()
True
set_output_text(output, html, sage=None)
set_worksheet(worksheet, id=None)

Sets the worksheet object of self to be worksheet and optionally changes the id of self.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: W = "worksheet object"
sage: C.set_worksheet(W)
sage: C.worksheet()
'worksheet object'
sage: C.set_worksheet(None, id=2)
sage: C.id()
2
stop_interacting()
system()

Returns the system used to evaluate this cell. The system is specified by a percent directive like ‘%maxima’ at the top of a cell.

If no system is explicitly specified, then None is returned which tells the notebook to evaluate the cell using the worksheet’s default system.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '%maxima\n2+3', '5', None)
sage: C.system()
'maxima'
sage: prefixes = ['%hide', '%time', '']
sage: cells = [sage.server.notebook.cell.Cell(0, '%s\n2+3'%prefix, '5', None) for prefix in prefixes]
sage: [(C, C.system()) for C in cells if C.system() is not None]
[]
time()

Returns True if the time it takes to evaluate this cell should be printed.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.time()
False
sage: C = sage.server.notebook.cell.Cell(0, '%time\n2+3', '5', None)
sage: C.time()
True
unset_introspect()

TODO: Figure out what the __introspect method is for and write a better doctest.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.set_introspect("a", "b")
sage: C.introspect()
['a', 'b']
sage: C.unset_introspect()
sage: C.introspect()
False
update_html_output(output='')

Update the list of files with html-style links or embeddings for this cell.

For interactive cells the html output section is always empty, mainly because there is no good way to distinguish content (e.g., images in the current directory) that goes into the interactive template and content that would go here.

url_to_self()

Returns a notebook URL for this cell.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.url_to_self()
'/home/sage/0/cells/0'
version()

Returns the version number of this cell.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.version()
0
sage: C.set_input_text('2+3')
sage: C.version()
1
word_wrap_cols()

Returns the number of columns for word wrapping. This defaults to 70, but the default setting for a notebook is 72.

EXAMPLES:

sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.word_wrap_cols()
70
sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.word_wrap_cols()
72
sage: import shutil; shutil.rmtree(nb.directory())
worksheet()

Returns the workseet associated to self.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.worksheet() is W
True
sage: import shutil; shutil.rmtree(nb.directory())
worksheet_filename()

Returns the filename of the worksheet associated to self.

EXAMPLES:

sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir())
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sage.server.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.worksheet_filename()
'sage/0'
sage: import shutil; shutil.rmtree(nb.directory())
class sage.server.notebook.cell.Cell_generic
delete_output()

Delete all output in this cell. This is not executed - it is an abstract function that must be overwritten in a derived class.

EXAMPLES: This function just raises a NotImplementedError, since it most be defined in derived class.

sage: C = sage.server.notebook.cell.Cell_generic()
sage: C.delete_output()
...
NotImplementedError
is_interactive_cell()

Returns True if this cell contains the use of interact either as a function call or a decorator.

EXAMPLES:

sage: from sage.server.notebook.cell import Cell_generic
sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: Cell_generic.is_interactive_cell(C)
False
sage.server.notebook.cell.ComputeCell
alias of Cell
class sage.server.notebook.cell.TextCell(id, text, worksheet)
__cmp__(right)

EXAMPLES:

sage: C1 = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C2 = sage.server.notebook.cell.TextCell(0, '3+2', None)
sage: C3 = sage.server.notebook.cell.TextCell(1, '2+3', None)
sage: C1 == C1
True
sage: C1 == C2
True
sage: C1 == C3
False
__init__(id, text, worksheet)

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C == loads(dumps(C))
True
__repr__()

String representation of this text cell.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.__repr__()
'TextCell 0: 2+3'
delete_output()

Delete all output in this cell. This does nothing since text cells have no output.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C
TextCell 0: 2+3
sage: C.delete_output()
sage: C
TextCell 0: 2+3
edit_text()

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.edit_text()
'2+3'
html(ncols=0, do_print=False, do_math_parse=True, editing=False)

Returns an HTML version of self as a string.

INPUT:

  • do_math_parse - bool (default: True) If True, call math_parse (defined in cell.py) on the html.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.html()
'<div class="text_cell" id="cell_text_0">2+3...'
sage: C.set_input_text("$2+3$")
sage: C.html(do_math_parse=True)
'<div class="text_cell" id="cell_text_0"><span class="math">2+3</span>...'
html_inner(ncols=0, do_print=False, do_math_parse=True, editing=False)

Returns an HTML version of the content of self as a string.

INPUT:

  • do_math_parse - bool (default: True) If True, call math_parse (defined in cell.py) on the html.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.html_inner()
'2+3...'
sage: C.set_input_text("$2+3$")
sage: C.html_inner(do_math_parse=True)
'<span class="math">2+3</span>...'
id()

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.id()
0
is_auto_cell()

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.is_auto_cell()
False
plain_text(prompts=False)

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.plain_text()
'2+3'
set_cell_output_type(typ='wrap')

This does nothing for TextCells.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C.set_cell_output_type("wrap")
set_input_text(input_text)

Sets the input text of self to be input_text.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: C
TextCell 0: 2+3
sage: C.set_input_text("3+2")
sage: C
TextCell 0: 3+2
set_worksheet(worksheet, id=None)

Sets the worksheet object of self to be worksheet and optionally changes the id of self.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', None)
sage: W = "worksheet object"
sage: C.set_worksheet(W)
sage: C.worksheet()
'worksheet object'
sage: C.set_worksheet(None, id=2)
sage: C.id()
2
worksheet()

Returns the worksheet object associated to self.

EXAMPLES:

sage: C = sage.server.notebook.cell.TextCell(0, '2+3', 'worksheet object')
sage: C.worksheet()
'worksheet object'
sage.server.notebook.cell.format_exception(s0, ncols)

Make it so exceptions don’t appear expanded by default.

INPUT:

  • s0 - string
  • ncols - integer

OUTPUT: string

If s0 contains “notracebacks” then this function always returns s0

EXAMPLES:

sage: sage.server.notebook.cell.format_exception(sage.server.notebook.cell.TRACEBACK,80)
'\nTraceback (click to the left for traceback)\n...\nTraceback (most recent call last):'
sage: sage.server.notebook.cell.format_exception(sage.server.notebook.cell.TRACEBACK + "notracebacks",80)
'Traceback (most recent call last):notracebacks'
sage.server.notebook.cell.number_of_rows(txt, ncols)

Returns the number of rows needed to display the string in txt if there are a maximum of ncols columns per row.

EXAMPLES:

sage: from sage.server.notebook.cell import number_of_rows
sage: s = "asdfasdf\nasdfasdf\n"
sage: number_of_rows(s, 8)
2
sage: number_of_rows(s, 5)
4
sage: number_of_rows(s, 4)
4

Previous topic

The Sage Notebook object

Next topic

A Worksheet.

This Page