Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66b7dfe

Browse files
committed
all seem to convert again
1 parent c5eb488 commit 66b7dfe

9 files changed

Lines changed: 39 additions & 4 deletions

File tree

converters/bloggerhtml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from converters.html import ConverterHTML
1+
from converters.html import ConverterHTML
2+
import io
23

34
class ConverterBloggerHTML(ConverterHTML):
45
"""Convert a notebook to html suitable for easy pasting into Blogger.

converters/html.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
from __future__ import absolute_import
2+
13
from converters.base import Converter
24
from converters.utils import text_cell, output_container
5+
from converters.utils import highlight, coalesce_streams, ansi2html
6+
7+
from IPython.utils import path
8+
from markdown import markdown
9+
import os
10+
import io
311

412
class ConverterHTML(Converter):
513
extension = 'html'
@@ -47,7 +55,7 @@ def header_body(self):
4755
os.path.join(css, 'notebook.css'),
4856
os.path.join(css, 'renderedhtml.css'),
4957
# our overrides:
50-
os.path.join(here, 'css', 'static_html.css'),
58+
os.path.join(here, '..','css', 'static_html.css'),
5159
]:
5260
header.extend(self._stylesheet(sheet))
5361

@@ -60,7 +68,7 @@ def header_body(self):
6068
header.extend(self.in_tag('script', '', {'type':'"text/javascript"',
6169
'src': '"https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"',
6270
}))
63-
with io.open(os.path.join(here, 'js', 'initmathjax.js'),
71+
with io.open(os.path.join(here, '..', 'js', 'initmathjax.js'),
6472
encoding='utf-8') as f:
6573
header.extend(self.in_tag('script', f.read(),
6674
{'type': '"text/javascript"'}))
File renamed without changes.

converters/markdown.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from converters.base import Converter
2+
from converters.utils import highlight, remove_ansi
3+
from IPython.utils.text import indent
24

35
class ConverterMarkdown(Converter):
46
extension = 'md'

converters/notebook.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from converters.base import Converter
2+
from shutil import rmtree
3+
import json
24

35
class ConverterNotebook(Converter):
46
"""

converters/python.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from converters.base import converter
1+
from converters.base import Converter
2+
from IPython.utils.text import indent
3+
from converters.utils import remove_ansi
24

35
class ConverterPy(Converter):
46
"""

converters/rst.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from converters.base import Converter
2+
from converters.utils import markdown2rst, rst_directive, remove_ansi
3+
from IPython.utils.text import indent
24

35
class ConverterRST(Converter):
46
extension = 'rst'

converters/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
from __future__ import print_function
2+
from lexers import IPythonLexer
23
import subprocess
34
import re
5+
from IPython.utils.text import indent
46

57
#-----------------------------------------------------------------------------
68
# Utility functions
79
#-----------------------------------------------------------------------------
10+
def highlight(src, lang='ipython'):
11+
"""Return a syntax-highlighted version of the input source.
12+
"""
13+
from pygments import highlight
14+
from pygments.lexers import get_lexer_by_name
15+
from pygments.formatters import HtmlFormatter
16+
17+
if lang == 'ipython':
18+
lexer = IPythonLexer()
19+
else:
20+
lexer = get_lexer_by_name(lang, stripall=True)
21+
22+
return highlight(src, lexer, HtmlFormatter())
23+
824
def output_container(f):
925
"""add a prompt-area next to an output"""
1026
def wrapped(self, output):

nbconvert.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
from converters.bloggerhtml import ConverterBloggerHTML
4343
from converters.rst import ConverterRST
4444
from converters.latex import ConverterLaTeX
45+
from converters.notebook import ConverterNotebook
46+
from converters.python import ConverterPy
4547

4648
known_formats = "rst (default), html, blogger-html, latex, markdown, py"
4749

0 commit comments

Comments
 (0)