Skip to content

Commit

Permalink
Merge pull request #1076 from t-makaro/jinjaext
Browse files Browse the repository at this point in the history
Improve template whitespacing
  • Loading branch information
MSeal authored Aug 6, 2019
2 parents 8ed20ca + 6fd7173 commit 54c6224
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions nbconvert/exporters/templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def from_notebook_node(self, nb, resources=None, **kw):

# Top level variables are passed to the template_exporter here.
output = self.template.render(nb=nb_copy, resources=resources)
output = output.lstrip('\r\n')
return output, resources

def _register_filter(self, environ, name, jinja_filter):
Expand Down
8 changes: 4 additions & 4 deletions nbconvert/templates/latex/article.tplx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

((=- Default to the notebook output style -=))
((* if not cell_style is defined *))
((*- if not cell_style is defined -*))
((* set cell_style = 'style_jupyter.tplx' *))
((* endif *))
((*- endif -*))

((=- Inherit from the specified cell style. -=))
((* extends cell_style *))
Expand All @@ -12,6 +12,6 @@
% Latex Article
%===============================================================================

((* block docclass *))
((*- block docclass -*))
\documentclass[11pt]{article}
((* endblock docclass *))
((*- endblock docclass -*))
18 changes: 9 additions & 9 deletions nbconvert/templates/latex/base.tplx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
((= Latex base template (must inherit)
((=- Latex base template (must inherit)
This template builds upon the abstract template, adding common latex output
functions. Figures, data_text,
This template does not define a docclass, the inheriting class must define this.=))
functions. Figures, data_text,
This template defines defines a default docclass, the inheriting class should
override this.-=))

((*- extends 'document_contents.tplx' -*))

%===============================================================================
% Abstract overrides
%===============================================================================

((* block header *))
((* block docclass *))((* endblock docclass *))
((*- block header -*))
((* block docclass *))\documentclass[11pt]{article}((* endblock docclass *))

((* block packages *))
\usepackage{iftex}
\ifPDFTeX
Expand Down Expand Up @@ -179,8 +180,7 @@ This template does not define a docclass, the inheriting class must define this.
((* endblock header *))

((* block body *))
\begin{document}

\begin{document}
((* block predoc *))
((* block maketitle *))\maketitle((* endblock maketitle *))
((* block abstract *))((* endblock abstract *))
Expand All @@ -192,5 +192,5 @@ This template does not define a docclass, the inheriting class must define this.
((* block postdoc *))
((* block bibliography *))((* endblock bibliography *))
((* endblock postdoc *))
\end{document}
\end{document}
((* endblock body *))
4 changes: 2 additions & 2 deletions nbconvert/templates/latex/skeleton/null.tplx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
((= Auto-generated template file, DO NOT edit directly!
To edit this file, please refer to ../../skeleton/README.md =))
((=- Auto-generated template file, DO NOT edit directly!
To edit this file, please refer to ../../skeleton/README.md -=))


((=
Expand Down
4 changes: 2 additions & 2 deletions nbconvert/templates/skeleton/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ all: clean $(TPLS)
# see http://flask.pocoo.org/snippets/55/ for more info
../latex/skeleton/%.tplx: %.tpl
@echo 'generating tex equivalent of $^: $@'
@echo '((= Auto-generated template file, DO NOT edit directly!\n' \
@echo '((=- Auto-generated template file, DO NOT edit directly!\n' \
' To edit this file, please refer to ../../skeleton/README.md' \
'=))\n\n' > $@
'-=))\n\n' > $@
@sed \
-e 's/{%/((*/g' \
-e 's/%}/*))/g' \
Expand Down

0 comments on commit 54c6224

Please sign in to comment.