diff --git a/templates/Makefile b/templates/Makefile new file mode 100644 index 0000000..0cd594c --- /dev/null +++ b/templates/Makefile @@ -0,0 +1,22 @@ + + +all: tex/null.tplx tex/display_priority.tplx + +# convert jinja syntax to tex +# cf http://flask.pocoo.org/snippets/55/ +tex/%.tplx: %.tpl + @echo 'generating tex equivalent of $^: $@' + @echo '((= autogenerated file do not edit =))' > $@ + @sed \ + -e 's/{%/((*/g' \ + -e 's/%}/*))/g' \ + -e 's/{{/(((/g' \ + -e 's/}}/)))/g' \ + -e 's/{#/((=/g' \ + -e 's/#}/=))/g' \ + $^ >> $@ + + +clean: + @echo "cleaning generated tplx files..." + @rm tex/* diff --git a/templates/tex/display_priority.tplx b/templates/tex/display_priority.tplx new file mode 100644 index 0000000..bc57368 --- /dev/null +++ b/templates/tex/display_priority.tplx @@ -0,0 +1,46 @@ +((= autogenerated file do not edit =)) +((*- extends 'null.tpl' -*)) + +((=display data priority=)) + + +((*- block data_priority scoped -*)) + ((*- for type in output | filter_data_type -*)) + ((*- if type in ['pdf']*)) + ((*- block data_pdf -*)) + ->> pdf + ((*- endblock -*)) + ((*- endif -*)) + ((*- if type in ['svg']*)) + ((*- block data_svg -*)) + ->> svg + ((*- endblock -*)) + ((*- endif -*)) + ((*- if type in ['png']*)) + ((*- block data_png -*)) + ->> png + ((*- endblock -*)) + ((*- endif -*)) + ((*- if type in ['html']*)) + ((*- block data_html -*)) + ->> html + ((*- endblock -*)) + ((*- endif -*)) + ((*- if type in ['jpeg']*)) + ((*- block data_jpg -*)) + ->> jpg + ((*- endblock -*)) + ((*- endif -*)) + ((*- if type in ['text']*)) + ((*- block data_text -*)) + ->> text + ((*- endblock -*)) + ((*- endif -*)) + + ((*- if type in ['latex']*)) + ((*- block data_latex -*)) + ->> latext + ((*- endblock -*)) + ((*- endif -*)) + ((*- endfor -*)) +((*- endblock data_priority -*)) diff --git a/templates/tex/null.tplx b/templates/tex/null.tplx new file mode 100644 index 0000000..3e94a9b --- /dev/null +++ b/templates/tex/null.tplx @@ -0,0 +1,90 @@ +((= autogenerated file do not edit =)) +((= + +DO NOT USE THIS AS A BASE WORK, +IF YOU ARE COPY AND PASTING THIS FILE +YOU ARE PROBABLY DOING THINGS WRONG. + +Null template, Does nothing except defining a basic structure +To layout the diferents blocks of a notebook. + +Subtemplates can Override Blocks to define their custom reresentation. + +If one of the block you do overrite is not a leave block, consider +calling super. + +((*- block nonLeaveBlock -*)) + #add stuff at beginning + ((( super() ))) + #add stuff at end +((*- endblock nonLeaveBlock -*)) + +consider calling super even if block is leave block, we might insert more block later. + +=)) +((*- block header -*)) +((*- endblock header -*)) +((*- block body -*)) +((*- for worksheet in nb.worksheets -*)) + ((*- for cell in worksheet.cells -*)) + ((*- block any_cell scoped -*)) + ((*- if cell.type in ['code'] -*)) + ((*- block codecell scoped -*)) + ((*- block input_group -*)) + ((*- block in_prompt -*))((*- endblock in_prompt -*)) + ((*- block input -*))((*- endblock input -*)) + ((*- endblock input_group -*)) + ((*- if cell.outputs -*)) + ((*- block output_group -*)) + ((*- block output_prompt -*))((*- endblock output_prompt -*)) + ((*- block outputs -*)) + ((*- for output in cell.outputs -*)) + ((*- if output.output_type in ['pyout'] -*)) + ((*- block pyout scoped -*))((*- endblock pyout -*)) + ((*- elif output.output_type in ['stream'] -*)) + ((*- block stream scoped -*)) + ((*- if output.stream in ['stdout'] -*)) + ((*- block stream_stdout scoped -*)) + ((*- endblock stream_stdout -*)) + ((*- elif output.stream in ['stderr'] -*)) + ((*- block stream_stderr scoped -*)) + ((*- endblock stream_stderr -*)) + ((*- endif -*)) + ((*- endblock stream -*)) + ((*- elif output.output_type in ['display_data'] -*)) + ((*- block display_data scoped -*)) + ((*- block data_priority scoped -*)) + ((*- endblock data_priority -*)) + ((*- endblock display_data -*)) + ((*- elif output.output_type in ['pyerr'] -*)) + ((*- block pyerr scoped -*)) + ((*- for line in output.traceback -*)) + ((*- block traceback_line scoped -*))((*- endblock traceback_line -*)) + ((*- endfor -*)) + ((*- endblock pyerr -*)) + ((*- endif -*)) + ((*- endfor -*)) + ((*- endblock outputs -*)) + ((*- endblock output_group -*)) + ((*- endif -*)) + ((*- endblock codecell -*)) + ((*- elif cell.type in ['markdown'] -*)) + ((*- block markdowncell scoped-*)) + ((*- endblock markdowncell -*)) + ((*- elif cell.type in ['heading'] -*)) + ((*- block headingcell scoped-*)) + ((*- endblock headingcell -*)) + ((*- elif cell.type in ['raw'] -*)) + ((*- block rawcell scoped-*)) + ((*- endblock rawcell -*)) + ((*- else -*)) + ((*- block unknowncell scoped-*)) + ((*- endblock unknowncell -*)) + ((*- endif -*)) + ((*- endblock any_cell -*)) + ((*- endfor -*)) +((*- endfor -*)) +((*- endblock body -*)) + +((*- block footer -*)) +((*- endblock footer -*))