Processes Sage documentation into notebook worksheet format with evaluable examples.
This takes in any HTML document, i.e., Sage documentation, and returns it in the editable format (like the notebook edit window). It also returns a string representing the CSS link for the document. The SGML parser is setup to return only the body of the HTML documentation page and to re-format Sage examples and type-setting.
Note: This extension of sgmllib.SGMLParser was partly inspired by Mark Pilgrim’s ‘Dive Into Python’ examples.
Author:
Bases: sgmllib.SGMLParser
Return the current cell count and increment it by one.
OUTPUT:
EXAMPLES:
sage: from sagenb.notebook.docHTMLProcessor import SphinxHTMLProcessor
sage: d = SphinxHTMLProcessor()
sage: d.get_cellcount()
0
sage: d.get_cellcount()
1
To separate the documentation’s content from the Sage examples, everything is split into one of two cell types. This method puts the current self.temp_pieces into self.all_pieces.
INPUT:
Process and return a cell_piece.
All divs with CSS class=”highlight” contain code examples. They include
INPUT:
OUTPUT:
Returns processed HTML input as HTML output. This is the only method that needs to be called externally.
INPUT:
OUTPUT:
Initialize necessary variables. Called by SGMLParser.__init__().
EXAMPLES:
sage: from sagenb.notebook.docHTMLProcessor import SphinxHTMLProcessor
sage: d = SphinxHTMLProcessor()
sage: d.bodyQ
False
sage: d.in_highlight_div
False
sage: d.temp_pieces
[]
sage: d.all_pieces
''
sage: d.cellcount
0
Set self.bodyQ to True upon finding the opening body tag.
INPUT:
EXAMPLES:
sage: from sagenb.notebook.docHTMLProcessor import SphinxHTMLProcessor
sage: d = SphinxHTMLProcessor()
sage: d.bodyQ
False
sage: d.start_body(None)
sage: d.bodyQ
True