##// END OF EJS Templates
Merge pull request #4174 from minrk/markup-templates...
Merge pull request #4174 from minrk/markup-templates various issues in markdown and rst templates - remove prompts from default output - add missing HTML block - remove double-wrapping of latex - use plain-markdown indentation for code blocks (could use GFM ``` ` ` `python```) - images didn't work in either one at all - markdown extracts output closes #4024

File last commit:

r12461:8c88aec6 merge
r12461:8c88aec6 merge
Show More
sphinx.tplx
472 lines | 16.6 KiB | text/plain | TextLexer
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 ((= NBConvert Sphinx-Latex Template
Jonathan Frederic
Added document level description and cleaned template up....
r9735
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the
template is derived directly from Sphinx source.
Jonathan Frederic
Added document level description and cleaned template up....
r9735
Jonathan Frederic
Almost have nbconvert working again...
r10630 Inheritance: null>display_priority
Jonathan Frederic
Added document level description and cleaned template up....
r9735
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 Note: For best display, use latex syntax highlighting. =))
Jonathan Frederic
Added document level description and cleaned template up....
r9735
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((*- extends 'display_priority.tplx' -*))
Jonathan Frederic
Added basic Sphinx template....
r9734
damianavila
Redo of fixing templates structure.
r11770
Jonathan Frederic
Fixed errors after testing...
r11742 \nonstopmode
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 %==============================================================================
% Declarations
%==============================================================================
Jonathan Frederic
Added a nice comment to explain the line splitting.
r9919 % In order to make sure that the input/output header follows the code it
Jonathan Frederic
Updated comments...
r9929 % preceeds, the needspace package is used to request that a certain
% amount of lines (specified by this variable) are reserved. If those
% lines aren't available on the current page, the documenter will break
% to the next page and the header along with accomanying lines will be
% rendered together. This value specifies the number of lines that
% the header will be forced to group with without a page break.
((*- set min_header_lines = 4 -*))
Jonathan Frederic
Added a nice comment to explain the line splitting.
r9919
Jonathan Frederic
Re-arrange imports, added some comments, general cleaning.
r9920 % This is the number of characters that are permitted per line. It's
% important that this limit is set so characters do not run off the
% edges of latex pages (since latex does not always seem smart enough
Jonathan Frederic
Updated comments...
r9929 % to prevent this in some cases.) This is only applied to textual output
Jonathan Frederic
Added notebook output formatting style
r9940 ((* if resources.sphinx.outputstyle == 'simple' *))
Jonathan Frederic
Removed extra spaces
r9960 ((*- set wrap_size = 85 -*))
Jonathan Frederic
Added notebook output formatting style
r9940 ((* elif resources.sphinx.outputstyle == 'notebook' *))
Jonathan Frederic
Removed extra spaces
r9960 ((*- set wrap_size = 70 -*))
Jonathan Frederic
Added notebook output formatting style
r9940 ((* endif *))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 %==============================================================================
% Header
%==============================================================================
Jonathan Frederic
Added basic Sphinx template....
r9734 ((* block header *))
Jonathan Frederic
Added Sphinx transformer....
r9772
Jonathan Frederic
Moved latex comments in to Jinja blocks so they show in the...
r9751 % Header, overrides base
Jonathan Frederic
Added Sphinx transformer....
r9772
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 % Make sure that the sphinx doc style knows who it inherits from.
\def\sphinxdocclass{(((parentdocumentclass)))}
Matthias BUSSONNIER
Do now wrap before converting md to latex...
r9809
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 % Declare the document class
MinRK
ensure filenames have posix-paths in latex on Windows
r11973 \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs | posix_path )))/sphinx(((documentclass)))}
Matthias BUSSONNIER
Do now wrap before converting md to latex...
r9809
% Imports
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 \usepackage[utf8]{inputenc}
Matthias BUSSONNIER
Do now wrap before converting md to latex...
r9809 \DeclareUnicodeCharacter{00A0}{\\nobreakspace}
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 \usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{times}
\usepackage{import}
MinRK
ensure filenames have posix-paths in latex on Windows
r11973 \usepackage[((( resources.sphinx.chapterstyle )))]{((( resources.sphinx.texinputs | posix_path )))/fncychap}
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 \usepackage{longtable}
MinRK
ensure filenames have posix-paths in latex on Windows
r11973 \usepackage{((( resources.sphinx.texinputs | posix_path )))/sphinx}
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 \usepackage{multirow}
Jonathan Frederic
Enforce strict Sphinx style on headers and doc. attrib....
r9774 \usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ucs}
\usepackage{enumerate}
Jonathan Frederic
Changed rule attachment logic....
r9928 % Used to make the Input/Output rules follow around the contents.
\usepackage{needspace}
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 % Pygments requirements
\usepackage{fancyvrb}
\usepackage{color}
jakobgager
Add missing color definintions to latex header
r10944 % ansi colors additions
\definecolor{darkgreen}{rgb}{.12,.54,.11}
\definecolor{lightgray}{gray}{.95}
\definecolor{brown}{rgb}{0.54,0.27,0.07}
\definecolor{purple}{rgb}{0.5,0.0,0.5}
\definecolor{darkgray}{gray}{0.25}
\definecolor{lightred}{rgb}{1.0,0.39,0.28}
\definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
\definecolor{lightblue}{rgb}{0.53,0.81,0.92}
\definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
\definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added notebook style input highlighting.
r9939 % Needed to box output/input
Jonathan Frederic
Finishing touches on notebook style...
r10035 \usepackage{tikz}
\usetikzlibrary{calc,arrows,shadows}
\usepackage[framemethod=tikz]{mdframed}
Jonathan Frederic
Added notebook style input highlighting.
r9939 \usepackage{alltt}
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781
Jonathan Frederic
Re-arrange imports, added some comments, general cleaning.
r9920 % Used to load and display graphics
\usepackage{graphicx}
\graphicspath{ {figs/} }
Jonathan Frederic
Added max height as page height for images.
r10124 \usepackage[Export]{adjustbox} % To resize
Jonathan Frederic
Removed extra spaces
r9960
Paul Ivanov
use grffile to support notebooks with spaces
r11994 % used so that images for notebooks which have spaces in the name can still be included
\usepackage{grffile}
Jonathan Frederic
Re-arrange imports, added some comments, general cleaning.
r9920
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 % For formatting output while also word wrapping.
\usepackage{listings}
Matthias BUSSONNIER
Do now wrap before converting md to latex...
r9809 \lstset{breaklines=true}
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 \lstset{basicstyle=\small\ttfamily}
Jonathan Frederic
Adjusted input/output font size...
r10133 \def\smaller{\fontsize{9.5pt}{9.5pt}\selectfont}
Jonathan Frederic
Re-arrange imports, added some comments, general cleaning.
r9920
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 %Pygments definitions
Jonathan Frederic
Moved sphinx template related resources into Sphinx namespace
r9937 ((( resources.sphinx.pygment_definitions )))
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added notebook style input highlighting.
r9939 %Set pygments styles if needed...
((* if resources.sphinx.outputstyle == 'notebook' *))
Jonathan Frederic
Finishing touches on notebook style...
r10035 \definecolor{nbframe-border}{rgb}{0.867,0.867,0.867}
\definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969}
\definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502}
\definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0}
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added notebook output formatting style
r9940 \newenvironment{ColorVerbatim}
Jonathan Frederic
Finishing touches on notebook style...
r10035 {\begin{mdframed}[%
roundcorner=1.0pt, %
backgroundcolor=nbframe-bg, %
userdefinedwidth=1\linewidth, %
leftmargin=0.1\linewidth, %
innerleftmargin=0pt, %
innerrightmargin=0pt, %
linecolor=nbframe-border, %
linewidth=1pt, %
usetwoside=false, %
everyline=true, %
innerlinewidth=3pt, %
innerlinecolor=nbframe-bg, %
middlelinewidth=1pt, %
middlelinecolor=nbframe-bg, %
outerlinewidth=0.5pt, %
Jonathan Frederic
Attempt to fix Out[] prompt not following output sometimes.
r10172 outerlinecolor=nbframe-border, %
needspace=0pt
Jonathan Frederic
Finishing touches on notebook style...
r10035 ]}
{\end{mdframed}}
\newenvironment{InvisibleVerbatim}
{\begin{mdframed}[leftmargin=0.1\linewidth,innerleftmargin=3pt,innerrightmargin=3pt, userdefinedwidth=1\linewidth, linewidth=0pt, linecolor=white, usetwoside=false]}
Jonathan Frederic
Added notebook style input highlighting.
r9939 {\end{mdframed}}
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added notebook style input highlighting.
r9939 \renewenvironment{Verbatim}[1][\unskip]
Jonathan Frederic
Adjusted input/output font size...
r10133 {\begin{alltt}\smaller}
Jonathan Frederic
Added notebook style input highlighting.
r9939 {\end{alltt}}
((* endif *))
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781
Jonathan Frederic
Re-arrange imports, added some comments, general cleaning.
r9920 % Help prevent overflowing lines due to urls and other hard-to-break
% entities. This doesn't catch everything...
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 \sloppy
Jonathan Frederic
Enforce strict Sphinx style on headers and doc. attrib....
r9774
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 % Document level variables
Jonathan Frederic
tex=latex
r11686 \title{((( resources.metadata.name | escape_latex )))}
\date{((( resources.sphinx.date | escape_latex )))}
\release{((( resources.sphinx.version | escape_latex )))}
\author{((( resources.sphinx.author | escape_latex )))}
\renewcommand{\releasename}{((( resources.sphinx.release | escape_latex )))}
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Re-arrange imports, added some comments, general cleaning.
r9920 % TODO: Add option for the user to specify a logo for his/her export.
\newcommand{\sphinxlogo}{}
% Make the index page of the document.
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 \makeindex
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 % Import sphinx document type specifics.
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 ((* block sphinxheader *))((* endblock sphinxheader *))
Jonathan Frederic
Made significant improvements to the Sphinx-Latex export...
r9736 ((* endblock header *))
Jonathan Frederic
Added basic Sphinx template....
r9734
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 %==============================================================================
% Body
%==============================================================================
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((* block body *))
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 ((* block bodyBegin *))
Jonathan Frederic
Moved latex comments in to Jinja blocks so they show in the...
r9751 % Body
Jonathan Frederic
Got pdflatex to work on this empty sphinx styled template.
r9740
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 % Start of the document
\begin{document}
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added option to remove title and center output
r9950 ((* if resources.sphinx.header *))
\maketitle
((* endif *))
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 ((* block toc *))
Jonathan Frederic
Added option to remove title and center output
r9950 \tableofcontents
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 ((* endblock toc *))
Jonathan Frederic
Added basic Sphinx template....
r9734
damianavila
Redo of fixing templates structure.
r11770 ((* endblock bodyBegin *))
((( super() )))
((* block bodyEnd *))
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746
\renewcommand{\indexname}{Index}
\printindex
Jonathan Frederic
Moved latex comments in to Jinja blocks so they show in the...
r9751
Brian E. Granger
Adding citation support.
r12265 ((* block bibliography *))
((* endblock bibliography *))
Jonathan Frederic
Moved latex comments in to Jinja blocks so they show in the...
r9751 % End of document
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 \end{document}
((* endblock bodyEnd *))
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((* endblock body *))
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 %==============================================================================
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746 % Footer
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 %==============================================================================
Jonathan Frederic
Made significant improvements to the Sphinx-Latex export...
r9736 ((* block footer *))
((* endblock footer *))
Jonathan Frederic
Got both of the main template formats from sphinx rendering....
r9746
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 %==============================================================================
% Headings
%
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 % Purpose: Format pynb headers as sphinx headers. Depending on the Sphinx
% style that is active, this will change. Thus sphinx styles will
% override the values here.
Jonathan Frederic
Added region headers, to help visually separate elements...
r9921 %==============================================================================
Jonathan Frederic
Moved latex comments in to Jinja blocks so they show in the...
r9751 ((* block headingcell -*))
Jonathan Frederic
Changed rule attachment logic....
r9928 \
Jonathan Frederic
Process header cells....
r9749 ((*- if cell.level == 1 -*))
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((* block h1 -*))part((* endblock h1 -*))
Jonathan Frederic
Process header cells....
r9749 ((*- elif cell.level == 2 -*))
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((* block h2 -*))chapter((* endblock h2 -*))
Jonathan Frederic
Process header cells....
r9749 ((*- elif cell.level == 3 -*))
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((* block h3 -*))section((* endblock h3 -*))
Jonathan Frederic
Process header cells....
r9749 ((*- elif cell.level == 4 -*))
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((* block h4 -*))subsection((* endblock h4 -*))
Jonathan Frederic
Process header cells....
r9749 ((*- elif cell.level == 5 -*))
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((* block h5 -*))subsubsection((* endblock h5 -*))
Jonathan Frederic
Process header cells....
r9749 ((*- elif cell.level == 6 -*))
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((* block h6 -*))paragraph((* endblock h6 -*))
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 ((= It's important to make sure that underscores (which tend to be common
in IPYNB file titles) do not make their way into latex. Sometimes this
causes latex to barf. =))
damianavila
Redo of fixing templates structure.
r11770 ((*- endif -*))
Jonathan Frederic
Fix, sphinx template not removing new lines from headers
r12453 {((( cell.source | replace('\n', ' ') | citation2latex | markdown2latex )))}
Jonathan Frederic
Moved latex comments in to Jinja blocks so they show in the...
r9751 ((*- endblock headingcell *))
Jonathan Frederic
Process header cells....
r9749
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
% Markdown
%
% Purpose: Convert markdown to latex. Here markdown2latex is explicitly
% called since we know we want latex output.
%==============================================================================
Jonathan Frederic
Enabled markdown blocks.
r9757 ((*- block markdowncell scoped-*))
Brian E. Granger
Addressing review comments....
r12299 ((( cell.source | citation2latex | markdown2latex )))
Jonathan Frederic
Enabled markdown blocks.
r9757 ((*- endblock markdowncell -*))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
% Rawcell
%
% Purpose: Raw text cells allow the user to manually inject document code that
% will not get touched by the templating system.
%==============================================================================
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((*- block rawcell *))
damianavila
Redo of fixing templates structure.
r11770 ((( cell.source | wrap_text(wrap_size) )))
Jonathan Frederic
Moved header definitions into individual sphinx doc types....
r9761 ((* endblock rawcell -*))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
% Unknowncell
%
% Purpose: This is the catch anything unhandled. To display this data, we
% remove all possible latex conflicts and wrap the characters so they
% can't flow off of the page.
%==============================================================================
((* block unknowncell scoped*))
damianavila
Redo of fixing templates structure.
r11770 % Unsupported cell type, no formatting
((( cell.source | wrap_text | escape_latex )))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 ((* endblock unknowncell *))
%==============================================================================
% Input
%==============================================================================
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((* block input *))
Jonathan Frederic
Added prompt to ntoebook style,...
r9943
% Make sure that atleast 4 lines are below the HR
\needspace{((( min_header_lines )))\baselineskip}
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added notebook style input highlighting.
r9939 ((* if resources.sphinx.outputstyle == 'simple' *))
% Add a horizantal break, along with break title.
\vspace{10pt}
{\scriptsize Input}\\*
\rule[10pt]{\linewidth}{0.5pt}
\vspace{-25pt}
% Add contents below.
Jonathan Frederic
Filter names cleanup
r11685 ((( cell.input | highlight2latex )))
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added notebook style input highlighting.
r9939 ((* elif resources.sphinx.outputstyle == 'notebook' *))
Jonathan Frederic
Adjusted input/output font size...
r10133 \vspace{6pt}
((( write_prompt("In", cell.prompt_number, "nbframe-in-prompt") )))
\vspace{-2.65\baselineskip}
Jonathan Frederic
Added notebook output formatting style
r9940 \begin{ColorVerbatim}
Jonathan Frederic
Adjusted input/output font size...
r10133 \vspace{-0.7\baselineskip}
Jonathan Frederic
Filter names cleanup
r11685 ((( cell.input | highlight2latex )))
Jonathan Frederic
Adjusted input/output font size...
r10133 ((* if cell.input == None or cell.input == '' *))
\vspace{0.3\baselineskip}
((* else *))
\vspace{-0.2\baselineskip}
((* endif *))
Jonathan Frederic
Added notebook style input highlighting.
r9939 \end{ColorVerbatim}
((* endif *))
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((* endblock input *))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
Jonathan Frederic
Localized code into jinja macros.
r9925 % Output_Group
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %
Jonathan Frederic
Localized code into jinja macros.
r9925 % Purpose: Make sure that only one header bar only attaches to the output
% once. By keeping track of when an input group is started
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
Jonathan Frederic
Changed rule attachment logic....
r9928 ((* block output_group *))
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 ((* if cell.outputs.__len__() > 0 *))
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Needspace for the output regardless of output style.
r10173 % If the first block is an image, minipage the image. Else
% request a certain amount of space for the input text.
((( iff_figure(cell.outputs[0], "\\begin{minipage}{1.0\\textwidth}", "\\needspace{" ~ min_header_lines ~ "\\baselineskip}") )))
((* if resources.sphinx.outputstyle == 'simple' *))
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 % Add a horizantal break, along with break title.
\vspace{10pt}
{\scriptsize Output}\\*
\rule[10pt]{\linewidth}{0.5pt}
\vspace{-20pt}
% Add the contents of the first block.
((( render_output(cell.outputs[0]) )))
% Close the minipage.
((( iff_figure(cell.outputs[0], "\\end{minipage}", "") )))
% Add remainer of the document contents below.
((* for output in cell.outputs[1:] *))
Jonathan Frederic
Finishing touches on notebook style...
r10035 ((( render_output(output, cell.prompt_number) )))
Jonathan Frederic
Added notebook output formatting style
r9940 ((* endfor *))
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 ((* elif resources.sphinx.outputstyle == 'notebook' *))
Jonathan Frederic
Removed extra spaces
r9960
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 % Add document contents.
Jonathan Frederic
Finishing touches on notebook style...
r10035 ((* for output in cell.outputs *))
((( render_output(output, cell.prompt_number) )))
((* endfor *))
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 ((* endif *))
Jonathan Frederic
Added notebook style input highlighting.
r9939 ((* endif *))
Jonathan Frederic
Localized code into jinja macros.
r9925 ((* endblock *))
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
Jonathan Frederic
Localized code into jinja macros.
r9925 % Additional formating
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((* block data_text *))
damianavila
Redo of fixing templates structure.
r11770 ((( custom_verbatim(output.text) | ansi2latex )))
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((* endblock *))
Jonathan Frederic
Localized code into jinja macros.
r9925 ((* block traceback_line *))
damianavila
Redo of fixing templates structure.
r11770 ((( conditionally_center_output( line | indent| strip_ansi ) )))
Jonathan Frederic
Localized code into jinja macros.
r9925 ((* endblock traceback_line *))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
% Supported image formats
%==============================================================================
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((*- block data_png -*))
MinRK
ensure filenames have posix-paths in latex on Windows
r11973 ((( conditionally_center_output(insert_graphics(output.png_filename | posix_path)) )))
Jonathan Frederic
Fixed image keys in templates to reflect changes to ExtractFigureTransformer....
r11471 ((*- endblock -*))
((*- block data_jpg -*))
MinRK
fix jpg/jpeg type in sphinx
r12452 ((( conditionally_center_output(insert_graphics(output.jpeg_filename | posix_path)) )))
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((*- endblock -*))
((*- block data_svg -*))
MinRK
ensure filenames have posix-paths in latex on Windows
r11973 ((( conditionally_center_output(insert_graphics(output.svg_filename | posix_path)) )))
Jonathan Frederic
Added HR, pygments, made HR attach to first n lines.
r9781 ((*- endblock -*))
MinRK
add data_pdf block to latex templates
r11574 ((*- block data_pdf -*))
MinRK
ensure filenames have posix-paths in latex on Windows
r11973 ((( conditionally_center_output(insert_graphics(output.pdf_filename | posix_path)) )))
MinRK
add data_pdf block to latex templates
r11574 ((*- endblock -*))
Jonathan Frederic
Finishing touches on notebook style...
r10035 ((*- block data_latex *))
damianavila
Redo of fixing templates structure.
r11770 ((* if resources.sphinx.centeroutput *))
\begin{center}
((* endif -*))
((( output.latex | strip_math_space )))
((*- if resources.sphinx.centeroutput *))
\end{center}
((* endif -*))
Jonathan Frederic
Output latex in now placed in verbatim safe for latex.
r9947 ((*- endblock -*))
Jonathan Frederic
Added prompt to ntoebook style,...
r9943
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 %==============================================================================
% Support Macros
%==============================================================================
Jonathan Frederic
Updated comments...
r9929
Jonathan Frederic
Adjusted input/output font size...
r10133 % Name: write_prompt
% Purpose: Renders an output/input prompt for notebook style pdfs
((* macro write_prompt(prompt, number, color) -*))
\makebox[0.1\linewidth]{\smaller\hfill\tt\color{((( color )))}((( prompt )))\hspace{4pt}{[}((( number ))){]}:\hspace{4pt}}\\*
((*- endmacro *))
Jonathan Frederic
Updated comments...
r9929 % Name: render_output
% Purpose: Renders an output block appropriately.
Jonathan Frederic
Finishing touches on notebook style...
r10035 ((* macro render_output(output, prompt_number) -*))
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 ((*- if output.output_type == 'pyerr' -*))
((*- block pyerr scoped *))
Jonathan Frederic
Removed extra spaces
r9960 ((( custom_verbatim(super()) )))
Jonathan Frederic
Added prompt to ntoebook style,...
r9943 ((* endblock pyerr -*))
((*- else -*))
Jonathan Frederic
Finishing touches on notebook style...
r10035
((* if resources.sphinx.outputstyle == 'notebook' *))
((*- if output.output_type == 'pyout' -*))
Jonathan Frederic
Adjusted input/output font size...
r10133 ((( write_prompt("Out", prompt_number, "nbframe-out-prompt") )))
Jonathan Frederic
Finishing touches on notebook style...
r10035 \vspace{-2.55\baselineskip}
((*- endif -*))
\begin{InvisibleVerbatim}
\vspace{-0.5\baselineskip}
((*- endif -*))
Jonathan Frederic
Changed rule attachment logic....
r9928 ((*- block display_data scoped -*))
((( super() )))
((*- endblock display_data -*))
Jonathan Frederic
Finishing touches on notebook style...
r10035
((* if resources.sphinx.outputstyle == 'notebook' *))
\end{InvisibleVerbatim}
((*- endif -*))
Jonathan Frederic
Changed rule attachment logic....
r9928 ((*- endif -*))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 ((*- endmacro *))
Jonathan Frederic
Updated comments...
r9929 % Name: iff_figure
% Purpose: If the output block provided is a figure type, the 'true_content'
% parameter will be returned. Else, the 'false_content'.
((* macro iff_figure(output, true_content, false_content) -*))
Jonathan Frederic
Image output detection for pyout
r9944 ((*- set is_figure = false -*))
((*- for type in output | filter_data_type -*))
Jonathan Frederic
Fixed typo, remove extra jpeg
r9945 ((*- if type in ['pdf', 'svg', 'png', 'jpeg','html']*))
Jonathan Frederic
Image output detection for pyout
r9944 ((*- set is_figure = true -*))
((*- endif -*))
((*- endfor -*))
((* if is_figure -*))
Jonathan Frederic
Updated comments...
r9929 ((( true_content )))
((*- else -*))
((( false_content )))
((*- endif *))
((*- endmacro *))
% Name: custom_verbatim
% Purpose: This macro creates a verbatim style block that fits the existing
% sphinx style more readily than standard verbatim blocks.
Jonathan Frederic
Changed rule attachment logic....
r9928 ((* macro custom_verbatim(text) -*))
Jonathan Frederic
Aesthetics - cleaned up nesting
r9963 \begin{alltt}
((*- if resources.sphinx.centeroutput *))\begin{center} ((* endif -*))
Jonathan Frederic
FIXED, latex characters not escaped properly in nbconvert
r12060 ((( text | wrap_text(wrap_size) | escape_latex )))
Jonathan Frederic
Aesthetics - cleaned up nesting
r9963 ((*- if resources.sphinx.centeroutput *))\end{center}((* endif -*))
\end{alltt}
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 ((*- endmacro *))
Jonathan Frederic
Changed center_output macro name to conditionally_center_output...
r10171 % Name: conditionally_center_output
Jonathan Frederic
Added option to remove title and center output
r9950 % Purpose: This macro centers the output if the output centering is enabled.
Jonathan Frederic
Changed center_output macro name to conditionally_center_output...
r10171 ((* macro conditionally_center_output(text) -*))
damianavila
Redo of fixing templates structure.
r11770 ((* if resources.sphinx.centeroutput *))
{\centering
((* endif *))
((( text )))
((* if resources.sphinx.centeroutput *))}
((* endif *))
Jonathan Frederic
Added option to remove title and center output
r9950 ((*- endmacro *))
Jonathan Frederic
Updated comments...
r9929 % Name: insert_graphics
% Purpose: This macro will insert an image in the latex document given a path.
Jonathan Frederic
Changed rule attachment logic....
r9928 ((* macro insert_graphics(path) -*))
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 \begin{center}
damianavila
Redo of fixing templates structure.
r11770 \includegraphics[max size={\textwidth}{\textheight}]{((( path )))}
Jonathan Frederic
Centeralized all "nbconvert sphinx block" logic (macros)...
r9922 \par
\end{center}
Paul Ivanov
use grffile to support notebooks with spaces
r11994 ((*- endmacro *))