本文整理汇总了Python中nbconvert.exporters.HTMLExporter.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLExporter.from_file方法的具体用法?Python HTMLExporter.from_file怎么用?Python HTMLExporter.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nbconvert.exporters.HTMLExporter
的用法示例。
在下文中一共展示了HTMLExporter.from_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_ipynb
# 需要导入模块: from nbconvert.exporters import HTMLExporter [as 别名]
# 或者: from nbconvert.exporters.HTMLExporter import from_file [as 别名]
def render_ipynb(full_path):
"""
Render a given ipynb file
"""
exporter = HTMLExporter()
with open(full_path, encoding='utf-8') as file_handle:
html, res = exporter.from_file(file_handle)
return Response(html, mimetype='text/html')
示例2: generate_exercises
# 需要导入模块: from nbconvert.exporters import HTMLExporter [as 别名]
# 或者: from nbconvert.exporters.HTMLExporter import from_file [as 别名]
def generate_exercises():
p = Path(*EXERCISES_DIR)
exporter = HTMLExporter()
exporter.register_preprocessor(ClearOutputPreprocessor(), enabled=True)
for exercise in p.iterdir():
if exercise.suffix == '.ipynb':
html, _ = exporter.from_file(exercise.open())
with open(exercise.with_suffix('.html').name, 'w') as f:
f.write(html)
示例3: reload
# 需要导入模块: from nbconvert.exporters import HTMLExporter [as 别名]
# 或者: from nbconvert.exporters.HTMLExporter import from_file [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
from nbconvert.exporters import HTMLExporter
from traitlets.config import Config
config = Config({
"HTMLExporter": {"template_file": "basic"},
'NbConvertBase': {
'display_data_priority': [
'text/html',
'text/markdown',
'application/pdf',
'image/svg+xml',
'text/latex',
'image/png',
'image/jpeg',
'text/plain',
]
}
})
ex = HTMLExporter(config=config)
html, extra = ex.from_file(sys.stdin)
sys.stdout.write(html)