document_contents.tplx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ((*- extends 'display_priority.tplx' -*))
  2. %===============================================================================
  3. % Support blocks
  4. %===============================================================================
  5. % Displaying simple data text
  6. ((* block data_text *))
  7. \begin{verbatim}
  8. ((( output.data['text/plain'] )))
  9. \end{verbatim}
  10. ((* endblock data_text *))
  11. % Display python error text as-is
  12. ((* block error *))
  13. \begin{Verbatim}[commandchars=\\\{\}]
  14. ((( super() )))
  15. \end{Verbatim}
  16. ((* endblock error *))
  17. ((* block traceback_line *))
  18. ((( line | indent | strip_ansi | escape_latex )))
  19. ((* endblock traceback_line *))
  20. % Display stream ouput with coloring
  21. ((* block stream *))
  22. \begin{Verbatim}[commandchars=\\\{\}]
  23. ((( output.text | escape_latex | ansi2latex )))
  24. \end{Verbatim}
  25. ((* endblock stream *))
  26. % Display latex
  27. ((* block data_latex -*))
  28. ((( output.data['text/latex'] | strip_files_prefix )))
  29. ((* endblock data_latex *))
  30. % Display markdown
  31. ((* block data_markdown -*))
  32. ((( output.data['text/markdown'] | citation2latex | strip_files_prefix | convert_pandoc('markdown+tex_math_double_backslash', 'latex'))))
  33. ((* endblock data_markdown *))
  34. % Default mechanism for rendering figures
  35. ((*- block data_png -*))((( draw_figure(output.metadata.filenames['image/png']) )))((*- endblock -*))
  36. ((*- block data_jpg -*))((( draw_figure(output.metadata.filenames['image/jpeg']) )))((*- endblock -*))
  37. ((*- block data_svg -*))((( draw_figure(output.metadata.filenames['image/svg+xml']) )))((*- endblock -*))
  38. ((*- block data_pdf -*))((( draw_figure(output.metadata.filenames['application/pdf']) )))((*- endblock -*))
  39. % Draw a figure using the graphicx package.
  40. ((* macro draw_figure(filename) -*))
  41. ((* set filename = filename | posix_path *))
  42. ((*- block figure scoped -*))
  43. \begin{center}
  44. \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{((( filename )))}
  45. \end{center}
  46. { \hspace*{\fill} \\}
  47. ((*- endblock figure -*))
  48. ((*- endmacro *))
  49. % Redirect execute_result to display data priority.
  50. ((* block execute_result scoped *))
  51. ((* block data_priority scoped *))
  52. ((( super() )))
  53. ((* endblock *))
  54. ((* endblock execute_result *))
  55. % Render markdown
  56. ((* block markdowncell scoped *))
  57. ((( cell.source | citation2latex | strip_files_prefix | convert_pandoc('markdown+tex_math_double_backslash', 'json',extra_args=[]) | resolve_references | convert_pandoc('json','latex'))))
  58. ((* endblock markdowncell *))
  59. % Don't display unknown types
  60. ((* block unknowncell scoped *))
  61. ((* endblock unknowncell *))