11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/nanoc/filters/nbconvert.rb', line 11
def run(content, params={})
nbconvert = <<'END'
import sys
from IPython.nbconvert import HTMLExporter
exportor = HTMLExporter(template_file="basic")
body, _ = exportor.from_file(sys.stdin)
sys.stdout.write(body)
END
python_bin = params[:python_bin] || 'python'
o, e, s = Open3.capture3("#{python_bin} -c '#{nbconvert}'",
:stdin_data=>content.to_s)
if !s.success?
raise "nbconvert fails: #{e}"
end
o
end
|