style_bw_ipython.tplx
45 lines
| 1.5 KiB
| text/plain
|
TextLexer
Jonathan Frederic
|
r12711 | ((= Black&white ipython input/output style =)) | ||
Thomas Kluyver
|
r13925 | ((*- extends 'base.tplx' -*)) | ||
Jonathan Frederic
|
r12711 | |||
%=============================================================================== | ||||
% Input | ||||
%=============================================================================== | ||||
((* block input scoped *)) | ||||
MinRK
|
r18580 | ((( add_prompt(cell.source, cell, 'In ') ))) | ||
Jonathan Frederic
|
r12711 | ((* endblock input *)) | ||
%=============================================================================== | ||||
% Output | ||||
%=============================================================================== | ||||
MinRK
|
r18580 | ((* block execute_result scoped *)) | ||
MinRK
|
r18589 | ((*- for type in output.data | filter_data_type -*)) | ||
((*- if type in ['text/plain']*)) | ||||
((( add_prompt(output.data['text/plain'], cell, 'Out') ))) | ||||
Jonathan Frederic
|
r12711 | ((*- else -*)) | ||
MinRK
|
r18587 | \verb+Out[((( cell.execution_count )))]:+((( super() ))) | ||
Jonathan Frederic
|
r12711 | ((*- endif -*)) | ||
((*- endfor -*)) | ||||
MinRK
|
r18580 | ((* endblock execute_result *)) | ||
Jonathan Frederic
|
r12711 | |||
%============================================================================== | ||||
% Support Macros | ||||
%============================================================================== | ||||
% Name: draw_prompt | ||||
% Purpose: Renders an output/input prompt | ||||
((* macro add_prompt(text, cell, prompt) -*)) | ||||
MinRK
|
r18587 | ((*- if cell.execution_count is defined -*)) | ||
((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) | ||||
Jessica B. Hamrick
|
r18345 | ((*- else -*)) | ||
MinRK
|
r18587 | ((*- set execution_count = " " -*)) | ||
Jessica B. Hamrick
|
r18345 | ((*- endif -*)) | ||
MinRK
|
r18587 | ((*- set indentation = " " * (execution_count | length + 7) -*)) | ||
Jonathan Frederic
|
r12720 | \begin{verbatim} | ||
MinRK
|
r18587 | (((- text | add_prompts(first=prompt ~ '[' ~ execution_count ~ ']: ', cont=indentation) -))) | ||
Jonathan Frederic
|
r12720 | \end{verbatim} | ||
Jonathan Frederic
|
r12711 | ((*- endmacro *)) | ||