-
Notifications
You must be signed in to change notification settings - Fork 38
/
style_bw_ipython.tex.j2
57 lines (48 loc) · 1.94 KB
/
style_bw_ipython.tex.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
((= Black&white ipython input/output style =))
((*- extends 'base.tex.j2' -*))
%===============================================================================
% Input
%===============================================================================
((* block input scoped *))
((*- if resources.global_content_filter.include_input_prompt *))
((( add_prompt(cell.source, cell, 'In ') )))
((* else *))
(((cell.source)))
((* endif -*))
((* endblock input *))
%===============================================================================
% Output
%===============================================================================
((* block execute_result scoped *))
((*- for type in output.data | filter_data_type -*))
((*- if resources.global_content_filter.include_output_prompt -*))
((*- if type in ['text/plain'] *))
((( add_prompt(output.data['text/plain'], cell, 'Out') )))
((*- else -*))
\verb+Out[((( cell.execution_count )))]:+((( super() )))
((*- endif -*))
((*- else -*))
((*- if type in ['text/plain'] *))
((( output.data['text/plain'] )))
((*- else -*))
\verb+((( super() )))
((*- endif -*))
((*- endif -*))
((*- endfor -*))
((* endblock execute_result *))
%==============================================================================
% Support Macros
%==============================================================================
% Name: draw_prompt
% Purpose: Renders an output/input prompt
((* macro add_prompt(text, cell, prompt) -*))
((*- if cell.execution_count is defined -*))
((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*))
((*- else -*))
((*- set execution_count = " " -*))
((*- endif -*))
((*- set indentation = " " * (execution_count | length + 7) -*))
\begin{verbatim}
(((- text | add_prompts(first=prompt ~ '[' ~ execution_count ~ ']: ', cont=indentation) -)))
\end{verbatim}
((*- endmacro *))