Ticket #10652: trac-10652-reviewer.patch

File trac-10652-reviewer.patch, 3.6 KB (added by jason, 11 years ago)

apply on top of previous patches

  • 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  
    11871187            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    11881188            sage: name = tmp_filename() + '.html'
    11891189            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 &mdash; 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>']))
    11981213            sage: fd.close()
    11991214            sage: W = nb._import_worksheet_html(name, 'admin')
    12001215            sage: W.name()
    1201             u'Test Notebook'
     1216            u'Test notebook -- test'
    12021217            sage: W.owner()
    12031218            'admin'
    12041219            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]
    12051231            sage: cell = W.cell_list()[1]
    12061232            sage: cell.input_text()
    12071233            u'1+1'
     
    12171243
    12181244        from twist import extract_title
    12191245        title = extract_title(doc_page_html).replace('&mdash;','--')
    1220         doc_page = title + '\nsystem:sage\n\n' + doc_page
    12211246
    12221247        worksheet = self.create_new_worksheet(title, owner)
    12231248        worksheet.edit_save(doc_page)
    12241249
    1225         #FIXME: For some reason, an extra cell gets added
    1226         #so we remove it here.
     1250        # FIXME: An extra compute cell is always added to the end.
     1251        # Pop it off.
    12271252        cells = worksheet.cell_list()
    12281253        cells.pop()
    12291254