Ticket #10652: trac-10652-reviewer.patch
File trac-10652-reviewer.patch, 3.6 KB (added by , 11 years ago) |
---|
-
sagenb/notebook/notebook.py
# HG changeset patch # User Jason Grout <jason.grout@drake.edu> # Date 1302042029 18000 # Node ID 18d1774c4f314685e59493301189c2876f65ce2e # Parent 33f1727409ea1a2cd12d692f3398f65306b81278 #10652: Reviewer patch that fixes the doctest and removes the title/system lines prepended to the worksheet since they didn't work. diff --git a/sagenb/notebook/notebook.py b/sagenb/notebook/notebook.py
a b 1187 1187 sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb') 1188 1188 sage: name = tmp_filename() + '.html' 1189 1189 sage: fd = open(name,'w') 1190 sage: fd.write('\n'.join( 1191 ... ['<html><head><title>Test Notebook</title></head>', 1192 ... '<body>', 1193 ... '<div class="highlight-python"><div class="highlight"><pre>', 1194 ... '<span class="gp">sage: </span><span class="mi">1</span><span class="o">+</span><span class="mi">1</span>', 1195 ... '<span class="go">2</span>', 1196 ... '</pre></div></div>', 1197 ... '</body></html>'])) 1190 sage: fd.write(''.join([ 1191 ... '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n', 1192 ... ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n', 1193 ... '\n', 1194 ... '<html xmlns="http://www.w3.org/1999/xhtml">\n', 1195 ... ' <head>\n', 1196 ... ' <title>Test notebook — test</title>\n', 1197 ... ' </head>\n', 1198 ... ' <body>\n', 1199 ... ' <div class="document">\n', 1200 ... ' <div class="documentwrapper">\n', 1201 ... ' <div class="bodywrapper">\n', 1202 ... ' <div class="body">\n', 1203 ... '<p>Here are some computations:</p>\n', 1204 ... '\n', 1205 ... '<div class="highlight-python"><div class="highlight"><pre>\n', 1206 ... '<span class="gp">sage', 1207 ... ': </span><span class="mi">1</span><span class="o">+</span><span class="mi">1</span>\n', 1208 ... '<span class="go">2</span>\n', 1209 ... '</pre></div></div>\n', 1210 ... '\n', 1211 ... '</div></div></div></div>\n', 1212 ... '</body></html>'])) 1198 1213 sage: fd.close() 1199 1214 sage: W = nb._import_worksheet_html(name, 'admin') 1200 1215 sage: W.name() 1201 u'Test Notebook'1216 u'Test notebook -- test' 1202 1217 sage: W.owner() 1203 1218 'admin' 1204 1219 sage: W.cell_list() 1220 [TextCell 1: <div class="document"> 1221 <div class="documentwrapper"> 1222 <div class="bodywrapper"> 1223 <div class="body"> 1224 <p>Here are some computations:</p> 1225 <BLANKLINE> 1226 <div class="highlight-python">, Cell 0; in=1+1, out= 1227 2 1228 , TextCell 2: </div> 1229 <BLANKLINE> 1230 </div></div></div></div] 1205 1231 sage: cell = W.cell_list()[1] 1206 1232 sage: cell.input_text() 1207 1233 u'1+1' … … 1217 1243 1218 1244 from twist import extract_title 1219 1245 title = extract_title(doc_page_html).replace('—','--') 1220 doc_page = title + '\nsystem:sage\n\n' + doc_page1221 1246 1222 1247 worksheet = self.create_new_worksheet(title, owner) 1223 1248 worksheet.edit_save(doc_page) 1224 1249 1225 # FIXME: For some reason, an extra cell gets added1226 # so we remove it here.1250 # FIXME: An extra compute cell is always added to the end. 1251 # Pop it off. 1227 1252 cells = worksheet.cell_list() 1228 1253 cells.pop() 1229 1254