From a50dfbab0cf373b71fbd891b248b0dc53ac581cd Mon Sep 17 00:00:00 2001 From: jfbu Date: Sat, 5 Nov 2016 16:43:13 +0100 Subject: [PATCH] add option to control if inline literal word-wraps in latex --- doc/latex.rst | 10 ++++++++++ sphinx/texinputs/sphinx.sty | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/latex.rst b/doc/latex.rst index 1e6eb6642..b26f629d3 100644 --- a/doc/latex.rst +++ b/doc/latex.rst @@ -151,6 +151,16 @@ Here are the currently available options together with their default values. before or after, but this is accessible currently only by re-defining some macros with complicated LaTeX syntax from :file:`sphinx.sty`. +``inlineliteralwraps`` + default ``true``. Allows linebreaks inside inline literals: but extra + potential break-points (additionally to those allowed by LaTeX at spaces + or for hyphenation) are currently inserted only after the characters ``. , + ; ? ! /``. Due to TeX internals, white space in the line will be stretched + (or shrinked) in order to accomodate the linebreak. + + .. versionadded:: 1.5 + set this option to ``false`` to recover former behaviour. + ``verbatimvisiblespace`` default ``\textcolor{red}{\textvisiblespace}``. When a long code line is split, space characters located at end of the line before the break are diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 8ae292aa2..c25b4d8e2 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -85,6 +85,7 @@ % verbatim \DeclareBoolOption[true]{verbatimwithframe} \DeclareBoolOption[true]{verbatimwrapslines} +\DeclareBoolOption[true]{inlineliteralwraps} % \textvisiblespace for compatibility with fontspec+XeTeX/LuaTeX \DeclareStringOption[\textcolor{red}{\textvisiblespace}]{verbatimvisiblespace} \DeclareStringOption % must use braces to hide the brackets @@ -243,7 +244,9 @@ % in 'alltt' \@noligs is done already, and the \scantokens must be avoided. \long\protected\def\sphinxcode#1{{\def\@tempa{alltt}% \ifx\@tempa\@currenvir\else - \sphinxbreaksviaactive\let\sphinxafterbreak\empty + \ifspx@opt@inlineliteralwraps + \sphinxbreaksviaactive\let\sphinxafterbreak\empty + \fi \@noligs\endlinechar\m@ne\everyeof{\noexpand}% \expandafter\scantokens \fi {\texttt{#1}}}}