Reputation: 1093
I'd like to remove the red and blue 'In' and 'Out' prompts when running nbconvert --to html
, based on cell metadata. With cell metadata such as:
{'cell_tags': {'cutcode_html': true}}
The following sucessfully removes the 'In'
prompt:
{% block input_group %}
{% if cell['metadata'].get('cell_tags',{}).get('cutcode_html','') == True -%}
<div></div>
{% else %}
{{ super() }}
{% endif %}
{% endblock input_group %}
I'd like to do the equivalent thing for the output prompt.
There has been discussion of how to do this for latex, but I can't figure out how to do it for HTML.
The output_prompt
blocks for HTML don't appear to do anything, and whenever I try to make slightly modified versions of the primary templates, they won't load properly.
Upvotes: 4
Views: 1530
Reputation: 12370
There is a command line option --no-prompt
nbconvert --to html --no-prompt
Upvotes: 1
Reputation: 20831
Currently, changing the output prompt is a bit more demanding because if you simply override the block output
by extending the full.tpl you have to include a super()
call to include the outputs. Unfortunately, the parent block (included by the super call) will add the Out prompt again and will mess up the html.
To get something similar to what you want, I did the following. (Note, I haven't included a complete template here, because the templates are currently changing due to the implementation of the v4 notebook format. Here, I'm using IPython 2.3)
block input_group
as you showed change the block output
to something like
{% block output %}
<div class="output_area">
{%- if cell['metadata'].get('cell_tags',{}).get('cutcode_html','') != True and output.output_type == 'pyout' -%}
<div class="prompt output_prompt">
Out[{{ cell.prompt_number }}]:
{%- else -%}
<div class="prompt">
{%- endif -%}
</div>
{{ super() }}
</div>
{% endblock output %}
With this I could convert a notebook with the prompts conditionally removed.
Upvotes: 2