nbconvert_template.tpl 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {%- extends 'markdown.tpl' -%}
  2. {%- block header -%}
  3. ---
  4. layout: docs
  5. docid: "{{resources['metadata']['name']}}"
  6. title: "{{resources['metadata']['name'].replace('_', ' ').title()}}"
  7. permalink: /docs/{{resources['metadata']['name']}}.html
  8. subsections:
  9. {%- for cell in nb['cells'] if cell.cell_type == 'markdown' and '##' in cell.source -%}
  10. {% for line in cell.source.split('\n') if line.startswith('##') %}
  11. - title: {{ line.lstrip('# ') }}
  12. id: {{ line.lstrip('# ').lower().replace(' ', '-') }}
  13. {%- endfor -%}
  14. {% endfor %}
  15. ---
  16. {%- endblock header -%}
  17. {%- block any_cell -%}
  18. {%- if not cell.metadata.get("block_hidden", False) -%}
  19. {{ super() }}
  20. {%- endif -%}
  21. {%- endblock any_cell -%}
  22. {% block input %}
  23. {%- if cell.source[:3] == "%%R" -%}
  24. ```R
  25. # R
  26. {{ '\n'.join(cell.source.split('\n')[1:]) }}
  27. ```
  28. {%- else -%}
  29. ```python
  30. # Python
  31. {{ cell.source }}
  32. ```
  33. {%- endif -%}
  34. {%- endblock input -%}
  35. {%- block output_group -%}
  36. {%- if not cell.metadata.get("output_hidden", False) -%}
  37. {{ super() }}
  38. {%- endif -%}
  39. {%- endblock output_group -%}
  40. {%- block input_group -%}
  41. {%- if not cell.metadata.get("input_hidden", False) -%}
  42. {{ super() }}
  43. {%- endif -%}
  44. {%- endblock input_group -%}
  45. {% block data_png %}
  46. ![png](/prophet/static/{{ output.metadata.filenames['image/png'] }})
  47. {% endblock data_png %}
  48. {% block markdowncell %}
  49. {%- set lines = cell.source.split('\n') -%}
  50. {%- for line in lines -%}
  51. {% if line.startswith('##') %}
  52. <a id="{{ line.lstrip('# ').lower().replace(' ', '-') }}"> </a>
  53. {% endif %}
  54. {{ line }}
  55. {% endfor %}
  56. {% endblock markdowncell %}