def _build(infile=None, outfile=None,
           reveal_prefix='reveal.js',
           template_file='templates/slides_reveal_local'):
    if infile is None:
        infile = "talk.ipynb" # load the name of your slideshow
    if outfile is None:
        outfile = "talk.slides.html"

    print('building {} to {}'.format(infile, outfile))

    notebook = open(infile).read()
    notebook_json = nbformat.reads_json(notebook)

    # This is the config object I talked before:
    # After the 'url_prefix', you can set the location of your
    # local reveal.js library, i.e. if the reveal.js is located
    # in the same directory as your talk.slides.html, then
    # set 'url_prefix':'reveal.js'.

    c = Config({
                'RevealHelpPreprocessor':{
                    'enabled':True,
                    'url_prefix':reveal_prefix,
                    },
                })

    exportHtml = SlidesExporter(config=c,
                                template_file=template_file)
    (body,resources) = exportHtml.from_notebook_node(notebook_json)

    # table -> bootstrap table
    body = body.replace('<table>',
                        '<table class="table table-striped">')

    # for all code blocks after "show me the code", no "input_hidden"
    show = body.find('数据预处理-训练集与特征')
    body = body[:show] + body[show:].replace('input_hidden', 'input')

    open(outfile, 'w').write(body)
Exemple #2
0
from IPython.config import Config

from IPython.nbformat import current as nbformat

infile = "Portfolio_Management.ipynb" # load the name of your slideshow
outfile = "Portfolio_Management.slides.html"

notebook = open(infile).read()
notebook_json = nbformat.reads_json(notebook)

# This is the config object I talked before: 
# After the 'url_prefix', you can set the location of your 
# local reveal.js library, i.e. if the reveal.js is located 
# in the same directory as your talk.slides.html, then 
# set 'url_prefix':'reveal.js'.

c = Config({
            'RevealHelpTransformer':{
                'enabled':True,
                'url_prefix':'reveal.js',
                },                
            })

print c

exportHtml = SlidesExporter(config=c)
(body,resources) = exportHtml.from_notebook_node(notebook_json)

open(outfile, 'w').write(body.encode('utf-8'))

Exemple #3
0
 def __init__(self):
     QtGui.QMainWindow.__init__(self)
     self.tabs = QtGui.QTabWidget(self,
                                  tabsClosable=True,
                                  movable=True,
                                  elideMode=QtCore.Qt.ElideRight,
                                  currentChanged=self.currentTabChanged,
                                  tabCloseRequested=self.closeTabRequested)
     self.bottom = QtWebKit.QWebView(self)
     self.setWindowTitle("vIPer")
     self.splitter = QtGui.QSplitter(self)
     self.setCentralWidget(self.splitter)
     self.splitter.addWidget(self.tabs)
     self.splitter.addWidget(self.bottom)
     self.bottom.setVisible(False)
     self.tabWidgets = []
     self.titleHistory = []
     self.path = QtCore.QDir.currentPath()
     self.newtab = QtGui.QAction(QtGui.QIcon.fromTheme("document-new"),
                                 "New Tab",
                                 self,
                                 triggered=self.newTabTriggered,
                                 shortcut="Ctrl+t")
     self.htmler = QtGui.QAction(QtGui.QIcon.fromTheme("go-down"),
                                 "Htmler",
                                 self,
                                 triggered=self.screenHtmled,
                                 shortcut="Ctrl+j")
     self.slider = QtGui.QAction(QtGui.QIcon.fromTheme("go-jump"),
                                 "Slider",
                                 self,
                                 triggered=self.screenSlided,
                                 shortcut="Ctrl+k")
     self.splitterV = QtGui.QAction(
         QtGui.QIcon.fromTheme("object-flip-vertical"),
         "Split vertically",
         self,
         triggered=self.screenSplittedVhtml,
         shortcut="F9")
     self.splitterV.setMenu(QtGui.QMenu())
     self.splitterV.menu().addAction(
         QtGui.QAction('HTML', self, triggered=self.screenSplittedVhtml))
     self.splitterV.menu().addAction(
         QtGui.QAction('SLIDE', self, triggered=self.screenSplittedVslide))
     self.splitterH = QtGui.QAction(
         QtGui.QIcon.fromTheme("object-flip-horizontal"),
         "Split horizontally",
         self,
         triggered=self.screenSplittedHhtml,
         shortcut="F10")
     self.splitterH.setMenu(QtGui.QMenu())
     self.splitterH.menu().addAction(
         QtGui.QAction('HTML', self, triggered=self.screenSplittedHhtml))
     self.splitterH.menu().addAction(
         QtGui.QAction('SLIDE', self, triggered=self.screenSplittedHslide))
     self.recorder = QtGui.QAction(
         QtGui.QIcon.fromTheme("media-playback-start"),
         "Record",
         self,
         triggered=self.screenRecorded,
         shortcut="Ctrl+r")
     self.stopper = QtGui.QAction(
         QtGui.QIcon.fromTheme("media-playback-stop"),
         "Stop",
         self,
         triggered=self.screenStopped,
         shortcut="Ctrl+Alt+s")
     self.addAction(
         QtGui.QAction("Split Screen",
                       self,
                       checkable=True,
                       toggled=self.splitToggled,
                       shortcut="F11"))
     self.addAction(
         QtGui.QAction("Full Screen",
                       self,
                       checkable=True,
                       toggled=self.screenToggled,
                       shortcut="F12"))
     self.helper = QtGui.QAction(QtGui.QIcon.fromTheme("help-faq"),
                                 "Help",
                                 self,
                                 triggered=self.newHelpTabTriggered,
                                 shortcut="Ctrl+h")
     self.full = HTMLExporter()
     self.html = '.html'
     self.rev = SlidesExporter()
     self.rev_html = '.slides.html'
     self.server = ServePostProcessor()
     self.servePool = []
     self.horizontal = QtCore.Qt.Horizontal
     self.vertical = QtCore.Qt.Vertical
     self.addTab(QtCore.QUrl('http://127.0.0.1:8888/'))