Skip to content

Commit 9cc3c1e

Browse files
committed
Add prompt option
GitHub: fix GH-9 We can hide "In [N]"/Out[N]" prompts by false. Reported by Julian Hatzky. Thanks!!!
1 parent d3b0e10 commit 9cc3c1e

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,33 @@ If you use kramdown as Markdown parser and get strange result, try to surround `
5353
{:/nomarkdown}
5454
```
5555

56+
## Configurations
57+
58+
You can customize `.ipynb` to `.html` conversion by `jupyter_notebook` in `_config.yml`:
59+
60+
```yaml
61+
jupyter_notebook:
62+
# ...
63+
```
64+
65+
### `prompt`
66+
67+
You can control whether a converted `.html` includes `In [N]`/`Out[N]` prompts or not by `prompt`:
68+
69+
```yaml
70+
jupyter_notebook:
71+
prompt: true
72+
```
73+
74+
The default value is `true`. It means that `In [N]`/`Out[N]` are shown.
75+
76+
You can remove them by using `false`:
77+
78+
```yaml
79+
jupyter_notebook:
80+
prompt: false
81+
```
82+
5683
## Authors
5784

5885
* Kouhei Sutou \<[email protected]\>

lib/jekyll-jupyter-notebook/converter.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def output_ext(ext)
2525
def convert(content)
2626
config = @config["jupyter_notebook"] || {}
2727

28-
html = convert_notebook(content)
28+
html = convert_notebook(content, config)
2929
html.sub!(/<link.+?href="custom.css">/, "")
3030
case config["content"] || "html"
3131
when "html"
@@ -42,17 +42,20 @@ def convert(content)
4242
end
4343

4444
private
45-
def convert_notebook(content)
45+
def convert_notebook(content, config)
4646
notebook = Tempfile.new(["jekyll-jupyter-notebook", ".ipynb"])
4747
notebook.print(content)
4848
notebook.close
4949
IO.pipe do |input, output|
50-
pid = spawn("jupyter",
51-
"nbconvert",
52-
"--to", "html",
53-
"--stdout",
54-
notebook.path,
55-
:out => output)
50+
command_line = [
51+
"jupyter",
52+
"nbconvert",
53+
"--to", "html",
54+
"--stdout",
55+
]
56+
command_line << "--no-prompt" unless config.fetch("prompt", true)
57+
command_line << notebook.path
58+
pid = spawn(*command_line, out: output)
5659
begin
5760
output.close
5861
html = nil

0 commit comments

Comments
 (0)