style_ipython.tplx
58 lines
| 2.0 KiB
| text/plain
|
TextLexer
Jonathan Frederic
|
r12719 | ((= IPython input/output style =)) | ||
Jonathan Frederic
|
r12718 | |||
Thomas Kluyver
|
r13925 | ((*- extends 'base.tplx' -*)) | ||
Jonathan Frederic
|
r12718 | |||
% Custom definitions | ||||
((* block definitions *)) | ||||
((( super() ))) | ||||
% Pygments definitions | ||||
Jonathan Frederic
|
r12742 | ((( resources.latex.pygments_definitions ))) | ||
Jonathan Frederic
|
r12718 | |||
Jonathan Frederic
|
r12734 | % Exact colors from NB | ||
\definecolor{incolor}{rgb}{0.0, 0.0, 0.5} | ||||
\definecolor{outcolor}{rgb}{0.545, 0.0, 0.0} | ||||
Jonathan Frederic
|
r12718 | ((* endblock definitions *)) | ||
%=============================================================================== | ||||
% Input | ||||
%=============================================================================== | ||||
((* block input scoped *)) | ||||
MinRK
|
r18580 | ((( add_prompt(cell.source | highlight_code(strip_verbatim=True), cell, 'In ', 'incolor') ))) | ||
Jonathan Frederic
|
r12718 | ((* 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'] | escape_latex, cell, 'Out', 'outcolor') ))) | ||||
Jonathan Frederic
|
r12718 | ((* else -*)) | ||
MinRK
|
r18587 | \texttt{\color{outcolor}Out[{\color{outcolor}((( cell.execution_count )))}]:}((( super() ))) | ||
Jonathan Frederic
|
r12718 | ((*- endif -*)) | ||
((*- endfor -*)) | ||||
MinRK
|
r18580 | ((* endblock execute_result *)) | ||
Jonathan Frederic
|
r12718 | |||
%============================================================================== | ||||
% Support Macros | ||||
%============================================================================== | ||||
% Name: draw_prompt | ||||
% Purpose: Renders an output/input prompt | ||||
((* macro add_prompt(text, cell, prompt, prompt_color) -*)) | ||||
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 indention = " " * (execution_count | length + 7) -*)) | ||
Jonathan Frederic
|
r12718 | \begin{Verbatim}[commandchars=\\\{\}] | ||
MinRK
|
r18587 | ((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) ))) | ||
Jonathan Frederic
|
r12718 | \end{Verbatim} | ||
((*- endmacro *)) | ||||