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