Rich Output for the Browser

class sage.repl.rich_output.output_browser.OutputHtml(html)[source]

Bases: OutputBase

HTML Output.

INPUT:

  • html – OutputBuffer. Alternatively, a string (bytes) can be passed directly which will then be converted into an OutputBuffer. String containing the html fragment code. Excludes the surrounding <body> and <html> tag.

EXAMPLES:

sage: from sage.repl.rich_output.output_catalog import OutputHtml
sage: OutputHtml('<div>Foo<b>B</b>ar</div>')
OutputHtml container
>>> from sage.all import *
>>> from sage.repl.rich_output.output_catalog import OutputHtml
>>> OutputHtml('<div>Foo<b>B</b>ar</div>')
OutputHtml container
classmethod example()[source]

Construct a sample Html output container.

This static method is meant for doctests, so they can easily construct an example.

OUTPUT: an instance of OutputHtml

EXAMPLES:

sage: from sage.repl.rich_output.output_catalog import OutputHtml
sage: OutputHtml.example()
OutputHtml container
sage: OutputHtml.example().html.get_str()
'<div>Hello World!</div>'
>>> from sage.all import *
>>> from sage.repl.rich_output.output_catalog import OutputHtml
>>> OutputHtml.example()
OutputHtml container
>>> OutputHtml.example().html.get_str()
'<div>Hello World!</div>'
print_to_stdout()[source]

Write the data to stdout.

This is just a convenience method to help with debugging.

EXAMPLES:

sage: from sage.repl.rich_output.output_catalog import OutputHtml
sage: rich_output = OutputHtml.example()
sage: rich_output.print_to_stdout()
<div>Hello World!</div>
>>> from sage.all import *
>>> from sage.repl.rich_output.output_catalog import OutputHtml
>>> rich_output = OutputHtml.example()
>>> rich_output.print_to_stdout()
<div>Hello World!</div>
with_html_tag()[source]

Return the HTML code surrounded by <html> tag.

This is just a convenience method.

EXAMPLES:

sage: from sage.repl.rich_output.output_catalog import OutputHtml
sage: rich_output = OutputHtml.example()
sage: rich_output.print_to_stdout()
<div>Hello World!</div>
sage: rich_output.with_html_tag()
'<html><div>Hello World!</div></html>'
>>> from sage.all import *
>>> from sage.repl.rich_output.output_catalog import OutputHtml
>>> rich_output = OutputHtml.example()
>>> rich_output.print_to_stdout()
<div>Hello World!</div>
>>> rich_output.with_html_tag()
'<html><div>Hello World!</div></html>'