|
| 1 | +{%- extends 'display_priority.j2' -%} |
| 2 | +{% from 'celltags.j2' import celltags %} |
| 3 | + |
| 4 | +{% block codecell %} |
| 5 | +{%- if not cell.outputs -%} |
| 6 | +{%- set no_output_class="jp-mod-noOutputs" -%} |
| 7 | +{%- endif -%} |
| 8 | +{%- if not resources.global_content_filter.include_input -%} |
| 9 | +{%- set no_input_class="jp-mod-noInput" -%} |
| 10 | +{%- endif -%} |
| 11 | +<div class="jp-Cell jp-CodeCell jp-Notebook-cell {{ no_output_class }} {{ no_input_class }} {{ celltags(cell) }}"> |
| 12 | +{{ super() }} |
| 13 | +</div> |
| 14 | +{%- endblock codecell %} |
| 15 | + |
| 16 | +{% block input_group -%} |
| 17 | +<div class="jp-Cell-inputWrapper"> |
| 18 | +<div class="jp-InputArea jp-Cell-inputArea"> |
| 19 | +{{ super() }} |
| 20 | +</div> |
| 21 | +</div> |
| 22 | +{% endblock input_group %} |
| 23 | + |
| 24 | +{% block input %} |
| 25 | +<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline"> |
| 26 | + <div class="CodeMirror cm-s-jupyter"> |
| 27 | +{{ cell.source | highlight_code(metadata=cell.metadata) }} |
| 28 | + </div> |
| 29 | +</div> |
| 30 | +{%- endblock input %} |
| 31 | + |
| 32 | +{% block output_group %} |
| 33 | +<div class="jp-Cell-outputWrapper"> |
| 34 | +{{ super() }} |
| 35 | +</div> |
| 36 | +{% endblock output_group %} |
| 37 | + |
| 38 | +{% block outputs %} |
| 39 | +<div class="jp-OutputArea jp-Cell-outputArea"> |
| 40 | +{{ super() }} |
| 41 | +</div> |
| 42 | +{% endblock outputs %} |
| 43 | + |
| 44 | +{% block in_prompt -%} |
| 45 | +<div class="jp-InputPrompt jp-InputArea-prompt"> |
| 46 | + {%- if cell.execution_count is defined -%} |
| 47 | + In [{{ cell.execution_count|replace(None, " ") }}]: |
| 48 | + {%- else -%} |
| 49 | + In [ ]: |
| 50 | + {%- endif -%} |
| 51 | +</div> |
| 52 | +{%- endblock in_prompt %} |
| 53 | + |
| 54 | +{% block empty_in_prompt -%} |
| 55 | +<div class="jp-InputPrompt jp-InputArea-prompt"> |
| 56 | +</div> |
| 57 | +{%- endblock empty_in_prompt %} |
| 58 | + |
| 59 | +{# |
| 60 | + output_prompt doesn't do anything in HTML, |
| 61 | + because there is a prompt div in each output area (see output block) |
| 62 | + #} |
| 63 | +{% block output_prompt %} |
| 64 | +{% endblock output_prompt %} |
| 65 | + |
| 66 | +{% block output_area_prompt %} |
| 67 | + <div class="jp-OutputPrompt jp-OutputArea-prompt"> |
| 68 | +{%- if output.output_type == 'execute_result' -%} |
| 69 | + {%- if cell.execution_count is defined -%} |
| 70 | + Out[{{ cell.execution_count|replace(None, " ") }}]: |
| 71 | + {%- else -%} |
| 72 | + Out[ ]: |
| 73 | + {%- endif -%} |
| 74 | +{%- endif -%} |
| 75 | + </div> |
| 76 | +{% endblock output_area_prompt %} |
| 77 | + |
| 78 | +{% block output %} |
| 79 | +<div class="jp-OutputArea-child"> |
| 80 | +{% if resources.global_content_filter.include_output_prompt %} |
| 81 | + {{ self.output_area_prompt() }} |
| 82 | +{% endif %} |
| 83 | +{{ super() }} |
| 84 | +</div> |
| 85 | +{% endblock output %} |
| 86 | + |
| 87 | +{% block markdowncell scoped %} |
| 88 | +<div class="jp-Cell-inputWrapper"> |
| 89 | +{%- if resources.global_content_filter.include_input_prompt-%} |
| 90 | + {{ self.empty_in_prompt() }} |
| 91 | +{%- endif -%} |
| 92 | +<div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput {{ celltags(cell) }}" data-mime-type="text/markdown"> |
| 93 | +{{ cell.source | markdown2html | strip_files_prefix }} |
| 94 | +</div> |
| 95 | +</div> |
| 96 | +{%- endblock markdowncell %} |
| 97 | + |
| 98 | +{% block unknowncell scoped %} |
| 99 | +unknown type {{ cell.type }} |
| 100 | +{% endblock unknowncell %} |
| 101 | + |
| 102 | +{% block execute_result -%} |
| 103 | +{%- set extra_class="jp-OutputArea-executeResult" -%} |
| 104 | +{% block data_priority scoped %} |
| 105 | +{{ super() }} |
| 106 | +{% endblock data_priority %} |
| 107 | +{%- set extra_class="" -%} |
| 108 | +{%- endblock execute_result %} |
| 109 | + |
| 110 | +{% block stream_stdout -%} |
| 111 | +<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain"> |
| 112 | +<pre> |
| 113 | +{{- output.text | ansi2html -}} |
| 114 | +</pre> |
| 115 | +</div> |
| 116 | +{%- endblock stream_stdout %} |
| 117 | + |
| 118 | +{% block stream_stderr -%} |
| 119 | +<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="application/vnd.jupyter.stderr"> |
| 120 | +<pre> |
| 121 | +{{- output.text | ansi2html -}} |
| 122 | +</pre> |
| 123 | +</div> |
| 124 | +{%- endblock stream_stderr %} |
| 125 | + |
| 126 | +{% block data_svg scoped -%} |
| 127 | +<div class="jp-RenderedSVG jp-OutputArea-output {{ extra_class }}" data-mime-type="image/svg+xml"> |
| 128 | +{%- if output.svg_filename %} |
| 129 | +<img src="{{ output.svg_filename | posix_path }}"> |
| 130 | +{%- else %} |
| 131 | +{{ output.data['image/svg+xml'] }} |
| 132 | +{%- endif %} |
| 133 | +</div> |
| 134 | +{%- endblock data_svg %} |
| 135 | + |
| 136 | +{% block data_html scoped -%} |
| 137 | +<div class="jp-RenderedHTMLCommon jp-RenderedHTML jp-OutputArea-output {{ extra_class }}" data-mime-type="text/html"> |
| 138 | +{{ output.data['text/html'] }} |
| 139 | +</div> |
| 140 | +{%- endblock data_html %} |
| 141 | + |
| 142 | +{% block data_markdown scoped -%} |
| 143 | +<div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-OutputArea-output {{ extra_class }}" data-mime-type="text/markdown"> |
| 144 | +{{ output.data['text/markdown'] | markdown2html }} |
| 145 | +</div> |
| 146 | +{%- endblock data_markdown %} |
| 147 | + |
| 148 | +{% block data_png scoped %} |
| 149 | +<div class="jp-RenderedImage jp-OutputArea-output {{ extra_class }}"> |
| 150 | +{%- if 'image/png' in output.metadata.get('filenames', {}) %} |
| 151 | +<img src="{{ output.metadata.filenames['image/png'] | posix_path }}" |
| 152 | +{%- else %} |
| 153 | +<img src="data:image/png;base64,{{ output.data['image/png'] }}" |
| 154 | +{%- endif %} |
| 155 | +{%- set width=output | get_metadata('width', 'image/png') -%} |
| 156 | +{%- if width is not none %} |
| 157 | +width={{ width }} |
| 158 | +{%- endif %} |
| 159 | +{%- set height=output | get_metadata('height', 'image/png') -%} |
| 160 | +{%- if height is not none %} |
| 161 | +height={{ height }} |
| 162 | +{%- endif %} |
| 163 | +{%- if output | get_metadata('unconfined', 'image/png') %} |
| 164 | +class="unconfined" |
| 165 | +{%- endif %} |
| 166 | +> |
| 167 | +</div> |
| 168 | +{%- endblock data_png %} |
| 169 | + |
| 170 | +{% block data_jpg scoped %} |
| 171 | +<div class="jp-RenderedImage jp-OutputArea-output {{ extra_class }}"> |
| 172 | +{%- if 'image/jpeg' in output.metadata.get('filenames', {}) %} |
| 173 | +<img src="{{ output.metadata.filenames['image/jpeg'] | posix_path }}" |
| 174 | +{%- else %} |
| 175 | +<img src="data:image/jpeg;base64,{{ output.data['image/jpeg'] }}" |
| 176 | +{%- endif %} |
| 177 | +{%- set width=output | get_metadata('width', 'image/jpeg') -%} |
| 178 | +{%- if width is not none %} |
| 179 | +width={{ width }} |
| 180 | +{%- endif %} |
| 181 | +{%- set height=output | get_metadata('height', 'image/jpeg') -%} |
| 182 | +{%- if height is not none %} |
| 183 | +height={{ height }} |
| 184 | +{%- endif %} |
| 185 | +{%- if output | get_metadata('unconfined', 'image/jpeg') %} |
| 186 | +class="unconfined" |
| 187 | +{%- endif %} |
| 188 | +> |
| 189 | +</div> |
| 190 | +{%- endblock data_jpg %} |
| 191 | + |
| 192 | +{% block data_latex scoped %} |
| 193 | +<div class="jp-RenderedLatex jp-OutputArea-output {{ extra_class }}" data-mime-type="text/latex"> |
| 194 | +{{ output.data['text/latex'] | e }} |
| 195 | +</div> |
| 196 | +{%- endblock data_latex %} |
| 197 | + |
| 198 | +{% block error -%} |
| 199 | +<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="application/vnd.jupyter.stderr"> |
| 200 | +<pre> |
| 201 | +{{- super() -}} |
| 202 | +</pre> |
| 203 | +</div> |
| 204 | +{%- endblock error %} |
| 205 | + |
| 206 | +{%- block traceback_line %} |
| 207 | +{{ line | ansi2html }} |
| 208 | +{%- endblock traceback_line %} |
| 209 | + |
| 210 | +{%- block data_text scoped %} |
| 211 | +<div class="jp-RenderedText jp-OutputArea-output {{ extra_class }}" data-mime-type="text/plain"> |
| 212 | +<pre> |
| 213 | +{{- output.data['text/plain'] | ansi2html -}} |
| 214 | +</pre> |
| 215 | +</div> |
| 216 | +{%- endblock -%} |
| 217 | + |
| 218 | +{# |
| 219 | + ############################################################################### |
| 220 | + # TODO: how to better handle JavaScript repr? # |
| 221 | + ############################################################################### |
| 222 | + #} |
| 223 | + |
| 224 | +{% set div_id = uuid4() %} |
| 225 | +{%- block data_javascript scoped %} |
| 226 | +<div id="{{ div_id }}" class="jp-RenderedJavaScript jp-OutputArea-output {{ extra_class }}" data-mime-type="application/javascript"> |
| 227 | +<script type="text/javascript"> |
| 228 | +var element = document.getElementById('{{ div_id }}'); |
| 229 | +{{ output.data['application/javascript'] }} |
| 230 | +</script> |
| 231 | +</div> |
| 232 | +{%- endblock -%} |
| 233 | + |
| 234 | +{%- block data_widget_state scoped %} |
| 235 | +{% set div_id = uuid4() %} |
| 236 | +{% set datatype_list = output.data | filter_data_type %} |
| 237 | +{% set datatype = datatype_list[0]%} |
| 238 | +<div id="{{ div_id }}" class="output_subarea output_widget_state {{ extra_class }}"> |
| 239 | +<script type="text/javascript"> |
| 240 | +var element = document.getElementById('{{ div_id }}'); |
| 241 | +</script> |
| 242 | +<script type="{{ datatype }}"> |
| 243 | +{{ output.data[datatype] | json_dumps }} |
| 244 | +</script> |
| 245 | +</div> |
| 246 | +{%- endblock data_widget_state -%} |
| 247 | + |
| 248 | +{%- block data_widget_view scoped %} |
| 249 | +{% set div_id = uuid4() %} |
| 250 | +{% set datatype_list = output.data | filter_data_type %} |
| 251 | +{% set datatype = datatype_list[0]%} |
| 252 | +<div id="{{ div_id }}" class="jupyter-widgets jp-OutputArea-output {{ extra_class }}"> |
| 253 | +<script type="text/javascript"> |
| 254 | +var element = document.getElementById('{{ div_id }}'); |
| 255 | +</script> |
| 256 | +<script type="{{ datatype }}"> |
| 257 | +{{ output.data[datatype] | json_dumps }} |
| 258 | +</script> |
| 259 | +</div> |
| 260 | +{%- endblock data_widget_view -%} |
| 261 | + |
| 262 | +{%- block footer %} |
| 263 | +{% set mimetype = 'application/vnd.jupyter.widget-state+json'%} |
| 264 | +{% if mimetype in nb.metadata.get("widgets",{})%} |
| 265 | +<script type="{{ mimetype }}"> |
| 266 | +{{ nb.metadata.widgets[mimetype] | json_dumps }} |
| 267 | +</script> |
| 268 | +{% endif %} |
| 269 | +{{ super() }} |
| 270 | +{%- endblock footer-%} |
0 commit comments