style_ipython.tplx
58 lines
| 2.0 KiB
| text/plain
|
TextLexer
|
r12719 | ((= IPython input/output style =)) | ||
|
r12718 | |||
|
r13925 | ((*- extends 'base.tplx' -*)) | ||
|
r12718 | |||
% Custom definitions | ||||
((* block definitions *)) | ||||
((( super() ))) | ||||
% Pygments definitions | ||||
|
r12742 | ((( resources.latex.pygments_definitions ))) | ||
|
r12718 | |||
|
r12734 | % Exact colors from NB | ||
\definecolor{incolor}{rgb}{0.0, 0.0, 0.5} | ||||
\definecolor{outcolor}{rgb}{0.545, 0.0, 0.0} | ||||
|
r12718 | ((* endblock definitions *)) | ||
%=============================================================================== | ||||
% Input | ||||
%=============================================================================== | ||||
((* block input scoped *)) | ||||
|
r18381 | ((( add_prompt(cell.input | highlight_code(strip_verbatim=True), cell, 'In ', 'incolor') ))) | ||
|
r12718 | ((* endblock input *)) | ||
%=============================================================================== | ||||
% Output | ||||
%=============================================================================== | ||||
((* block pyout scoped *)) | ||||
((*- for type in output | filter_data_type -*)) | ||||
((*- if type in ['text']*)) | ||||
((( add_prompt(output.text | escape_latex, cell, 'Out', 'outcolor') ))) | ||||
((* else -*)) | ||||
|
r12734 | \texttt{\color{outcolor}Out[{\color{outcolor}((( cell.prompt_number )))}]:}((( super() ))) | ||
|
r12718 | ((*- endif -*)) | ||
((*- endfor -*)) | ||||
((* endblock pyout *)) | ||||
%============================================================================== | ||||
% Support Macros | ||||
%============================================================================== | ||||
% Name: draw_prompt | ||||
% Purpose: Renders an output/input prompt | ||||
((* macro add_prompt(text, cell, prompt, prompt_color) -*)) | ||||
|
r18345 | ((*- if cell.prompt_number is defined -*)) | ||
|
r18328 | ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*)) | ||
|
r18345 | ((*- else -*)) | ||
((*- set prompt_number = " " -*)) | ||||
((*- endif -*)) | ||||
|
r12736 | ((*- set indention = " " * (prompt_number | length + 7) -*)) | ||
|
r12718 | \begin{Verbatim}[commandchars=\\\{\}] | ||
|
r12736 | ((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ prompt_number ~ '}]:} ', cont=indention) ))) | ||
|
r12718 | \end{Verbatim} | ||
((*- endmacro *)) | ||||