Skip to content

Commit

Permalink
Merge pull request #2 from jeremiahbuddha/heading_cell
Browse files Browse the repository at this point in the history
Added heading cell converter.
  • Loading branch information
slojo404 committed Mar 12, 2012
2 parents d83ec56 + 81978dd commit 45762dc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
15 changes: 12 additions & 3 deletions nbconvert.py
Expand Up @@ -27,6 +27,14 @@ def unknown_cell(cell):
return rst_directive('.. warning:: Unknown cell') + \
[repr(cell)]

def heading_cell(cell):
"""convert a heading cell to rst
Returns list."""
heading_level = {1:'=', 2:'-', 3:'`', 4:'\'', 5:'.',6:'~'}
marker = heading_level[cell.level]
return ['{0}\n{1}\n'.format(cell.source, marker*len(cell.source))]

def markdown_cell(cell):
"""convert a markdown cell to rst
Expand Down Expand Up @@ -97,7 +105,8 @@ def out_pyout(output):
return lines


converters = dict(code = code_cell,
converters = dict(heading = heading_cell,
code = code_cell,
markdown = markdown_cell,
pyout = out_pyout,
display_data = out_display,
Expand Down Expand Up @@ -165,13 +174,13 @@ def rst2simplehtml(fname):
# This may only work if there's a real title defined so we get a 'div class'
# tag, I haven't really tried.
for line in walker:
if line.startswith('<div class'):
if line.startswith('<body>'):
break

newfname = os.path.splitext(fname)[0] + '.html'
with open(newfname, 'w') as f:
for line in walker:
if line.startswith('</div>'):
if line.startswith('</body>'):
break
f.write(line)
f.write('\n')
Expand Down
22 changes: 22 additions & 0 deletions work_flow.txt
@@ -0,0 +1,22 @@
IPython Development Workflow

# Get a read only copy of the "master"
git clone git://github.com/ipython/nbconvert.git

# Add a copy of the master to your github account
git remote add ocefpaf git@github.com:ocefpaf/nbconvert.git

# Start a new branch to work on
git checkout -b your_new_branch

# Push updates to your local branch to your github branch
git push --set-upstream ocefpaf math_test:math_test

( merging your updated github branch into the master is done via pull-request on the website)

# Delete local branch
git branch -d math_test

# Delete remote branch
git push ocefpaf :math_test

0 comments on commit 45762dc

Please sign in to comment.