本文整理汇总了Python中nbconvert.HTMLExporter.exclude_input_prompt方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLExporter.exclude_input_prompt方法的具体用法?Python HTMLExporter.exclude_input_prompt怎么用?Python HTMLExporter.exclude_input_prompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nbconvert.HTMLExporter
的用法示例。
在下文中一共展示了HTMLExporter.exclude_input_prompt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HTMLExporter
# 需要导入模块: from nbconvert import HTMLExporter [as 别名]
# 或者: from nbconvert.HTMLExporter import exclude_input_prompt [as 别名]
import os.path, re, nbformat, jupyter_contrib_nbextensions
from nbconvert.preprocessors import Preprocessor
from nbconvert import HTMLExporter
from traitlets.config import Config
from pathlib import Path
__all__ = ['read_nb', 'convert_nb', 'convert_all']
exporter = HTMLExporter(Config())
exporter.exclude_input_prompt=True
exporter.exclude_output_prompt=True
#Loads the template to deal with hidden cells.
exporter.template_file = 'jekyll.tpl'
path = Path(__file__).parent
exporter.template_path.append(str(path))
def read_nb(fname):
"Read the notebook in `fname`."
with open(fname,'r') as f: return nbformat.reads(f.read(), as_version=4)
def convert_nb(fname, dest_path='.'):
"Convert a notebook `fname` to html file in `dest_path`."
from .gen_notebooks import remove_undoc_cells, remove_code_cell_jupyter_widget_state_elem
nb = read_nb(fname)
nb['cells'] = remove_undoc_cells(nb['cells'])
nb['cells'] = remove_code_cell_jupyter_widget_state_elem(nb['cells'])
fname = Path(fname).absolute()
dest_name = fname.with_suffix('.html').name
meta = nb['metadata']
meta_jekyll = meta['jekyll'] if 'jekyll' in meta else {'title': fname.with_suffix('').name}
meta_jekyll['nb_path'] = f'{fname.parent.name}/{fname.name}'