style_bw_ipython.tplx 1.9 KB

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