From 2e27b87202f5ea8d787dc42818acb7124079dbd3 2014-10-15 20:31:25 From: Jessica B. Hamrick Date: 2014-10-15 20:31:25 Subject: [PATCH] Handle case where prompt number is not defined in latex templates --- diff --git a/IPython/nbconvert/templates/latex/style_bw_ipython.tplx b/IPython/nbconvert/templates/latex/style_bw_ipython.tplx index 256873c..7aa97bf 100644 --- a/IPython/nbconvert/templates/latex/style_bw_ipython.tplx +++ b/IPython/nbconvert/templates/latex/style_bw_ipython.tplx @@ -33,7 +33,11 @@ % Name: draw_prompt % Purpose: Renders an output/input prompt ((* macro add_prompt(text, cell, prompt) -*)) + ((*- if cell.prompt_number is defined -*)) ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*)) + ((*- else -*)) + ((*- set prompt_number = " " -*)) + ((*- endif -*)) ((*- set indentation = " " * (prompt_number | length + 7) -*)) \begin{verbatim} (((- text | add_prompts(first=prompt ~ '[' ~ prompt_number ~ ']: ', cont=indentation) -))) diff --git a/IPython/nbconvert/templates/latex/style_ipython.tplx b/IPython/nbconvert/templates/latex/style_ipython.tplx index c89abbb..5eb7b9d 100644 --- a/IPython/nbconvert/templates/latex/style_ipython.tplx +++ b/IPython/nbconvert/templates/latex/style_ipython.tplx @@ -46,7 +46,11 @@ % Name: draw_prompt % Purpose: Renders an output/input prompt ((* macro add_prompt(text, cell, prompt, prompt_color) -*)) + ((*- if cell.prompt_number is defined -*)) ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*)) + ((*- else -*)) + ((*- set prompt_number = " " -*)) + ((*- endif -*)) ((*- set indention = " " * (prompt_number | length + 7) -*)) \begin{Verbatim}[commandchars=\\\{\}] ((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ prompt_number ~ '}]:} ', cont=indention) )))