rst.tpl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {%- extends 'display_priority.tpl' -%}
  2. {% block in_prompt %}
  3. {% endblock in_prompt %}
  4. {% block output_prompt %}
  5. {% endblock output_prompt %}
  6. {% block input scoped%}
  7. {%- if cell.source.strip() -%}
  8. {{".. code:: "-}}
  9. {%- if 'magics_language' in cell.metadata -%}
  10. {{ cell.metadata.magics_language}}
  11. {%- elif 'pygments_lexer' in nb.metadata.get('language_info', {}) -%}
  12. {{ nb.metadata.language_info.pygments_lexer }}
  13. {%- elif 'name' in nb.metadata.get('language_info', {}) -%}
  14. {{ nb.metadata.language_info.name }}
  15. {%- endif %}
  16. {{ cell.source | indent}}
  17. {% endif -%}
  18. {% endblock input %}
  19. {% block error %}
  20. ::
  21. {{ super() }}
  22. {% endblock error %}
  23. {% block traceback_line %}
  24. {{ line | indent | strip_ansi }}
  25. {% endblock traceback_line %}
  26. {% block execute_result %}
  27. {% block data_priority scoped %}
  28. {{ super() }}
  29. {% endblock %}
  30. {% endblock execute_result %}
  31. {% block stream %}
  32. .. parsed-literal::
  33. {{ output.text | indent }}
  34. {% endblock stream %}
  35. {% block data_svg %}
  36. .. image:: {{ output.metadata.filenames['image/svg+xml'] | urlencode }}
  37. {% endblock data_svg %}
  38. {% block data_png %}
  39. .. image:: {{ output.metadata.filenames['image/png'] | urlencode }}
  40. {%- set width=output | get_metadata('width', 'image/png') -%}
  41. {%- if width is not none %}
  42. :width: {{ width }}px
  43. {%- endif %}
  44. {%- set height=output | get_metadata('height', 'image/png') -%}
  45. {%- if height is not none %}
  46. :height: {{ height }}px
  47. {%- endif %}
  48. {% endblock data_png %}
  49. {% block data_jpg %}
  50. .. image:: {{ output.metadata.filenames['image/jpeg'] | urlencode }}
  51. {%- set width=output | get_metadata('width', 'image/jpeg') -%}
  52. {%- if width is not none %}
  53. :width: {{ width }}px
  54. {%- endif %}
  55. {%- set height=output | get_metadata('height', 'image/jpeg') -%}
  56. {%- if height is not none %}
  57. :height: {{ height }}px
  58. {%- endif %}
  59. {% endblock data_jpg %}
  60. {% block data_markdown %}
  61. {{ output.data['text/markdown'] | convert_pandoc("markdown", "rst") }}
  62. {% endblock data_markdown %}
  63. {% block data_latex %}
  64. .. math::
  65. {{ output.data['text/latex'] | strip_dollars | indent }}
  66. {% endblock data_latex %}
  67. {% block data_text scoped %}
  68. .. parsed-literal::
  69. {{ output.data['text/plain'] | indent }}
  70. {% endblock data_text %}
  71. {% block data_html scoped %}
  72. .. raw:: html
  73. {{ output.data['text/html'] | indent }}
  74. {% endblock data_html %}
  75. {% block markdowncell scoped %}
  76. {{ cell.source | convert_pandoc("markdown", "rst") }}
  77. {% endblock markdowncell %}
  78. {%- block rawcell scoped -%}
  79. {%- if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %}
  80. {{cell.source}}
  81. {% endif -%}
  82. {%- endblock rawcell -%}
  83. {% block headingcell scoped %}
  84. {{ ("#" * cell.level + cell.source) | replace('\n', ' ') | convert_pandoc("markdown", "rst") }}
  85. {% endblock headingcell %}
  86. {% block unknowncell scoped %}
  87. unknown type {{cell.type}}
  88. {% endblock unknowncell %}