Skip to content

Commit

Permalink
Merge pull request #1077 from t-makaro/fix_latex_ansi
Browse files Browse the repository at this point in the history
fix ansi2latex filtering
  • Loading branch information
t-makaro authored Aug 1, 2019
2 parents 8e3cfb4 + 5797e3c commit ed505f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions nbconvert/exporters/templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
'get_metadata': filters.get_metadata,
'convert_pandoc': filters.convert_pandoc,
'json_dumps': json.dumps,
'strip_trailing_newline': filters.strip_trailing_newline,
}

class ExtensionTolerantLoader(BaseLoader):
Expand Down
9 changes: 9 additions & 0 deletions nbconvert/filters/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'add_prompts',
'ascii_only',
'prevent_list_blocks',
'strip_trailing_newline',
]


Expand Down Expand Up @@ -241,3 +242,11 @@ def prevent_list_blocks(s):
out = re.sub('(^\s*)\+', '\\1\+', out)
out = re.sub('(^\s*)\*', '\\1\*', out)
return out

def strip_trailing_newline(text):
"""
Strips a newline from the end of text.
"""
if text.endswith('\n'):
text = text[:-1]
return text
2 changes: 1 addition & 1 deletion nbconvert/templates/latex/style_jupyter.tplx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@

((* block stream *))
\begin{Verbatim}[commandchars=\\\{\}]
((( output.text | wrap_text(charlim) | escape_latex | ansi2latex -)))
((( output.text | wrap_text(charlim) | escape_latex | strip_trailing_newline | ansi2latex )))
\end{Verbatim}
((* endblock stream *))

Expand Down

0 comments on commit ed505f4

Please sign in to comment.